用户测试/组测试的架构

发布于 2024-11-09 07:49:51 字数 725 浏览 0 评论 0原文

我有一个用户可以执行测试的用例。这是基于邀请的。因此,管理员可以向用户发送邀请以执行选定的测试。还可以创建一个由多个用户组成的团队,并向团队的所有用户发送邀请以执行该团队的测试。

创建这些模型有多种选择,但我不确定什么是最好的方法(或者甚至可能有替代方法)。

选项 1

  • 用户: id, name
  • 团队: id, name
  • UserTeam: user_id, team_id
  • UserInvite: id, user_id
  • TeamInvite: id, team_id
  • 测试: id, user_id, user_invite_id (可以为 null), team_invite_id (可以为 null),输入 [user|team]

选项 2

  • 用户:id、名称
  • 团队:id、名称
  • UserTeam:user_id,team_id
  • 邀请:id,user_id(可以为空),team_id(可以为空),类型 [user|team]
  • 测试:id,user_id,invite_id

那么是否有单独的邀请(对于团队和用户)更好并将测试链接到团队邀请或用户邀请(如选项 1)。或者另一种选择:有一个邀请,然后确定它是否链接到团队或用户(如选项 2)?

I have a use case where a User can perform a Test. This is based on an Invite. So an admin can send an Invite to a User to perform a selected Test. It is also possible to create a Team of several Users and send an Invite to all the users of a Team to perform the Test for that Team.

There are several options to create these models, but I am not sure what is the best way (or perhaps there is even an alternative).

Option 1

  • User: id, name
  • Team: id, name
  • UserTeam: user_id, team_id
  • UserInvite: id, user_id
  • TeamInvite: id, team_id
  • Test: id, user_id, user_invite_id (can be null), team_invite_id (can be null), type [user|team]

Option 2

  • User: id, name
  • Team: id, name
  • UserTeam: user_id, team_id
  • Invite: id, user_id (can be null), team_id (can be null), type [user|team]
  • Test: id, user_id, invite_id

So is it better to have seperate invites (for teams and users) and link the tests to a team-invite or a user-invite (like option 1). Or the alternative: have a single invite and determine then if it's linked to a team or a user (like option 2)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

想念有你 2024-11-16 07:49:51

就我个人而言,我会选择你的第二个选择。

不过,您可能还想研究第三个选项。它可以存储发送给多个团队和用户的邀请:

user: id, name
team: id, name
invite: id
test: id, invite_id
user_invite: invite_id, user_id
team_invite: invite_id, team_id

Personally, I'd go with your second option.

You might also want to investigate this third option, however. It makes it possible to store an invite sent to multiple teams and users:

user: id, name
team: id, name
invite: id
test: id, invite_id
user_invite: invite_id, user_id
team_invite: invite_id, team_id
雪若未夕 2024-11-16 07:49:51

您还可以将 Team 定义为特殊的 User,其中 Team.id 既是 Primary Key 又是外键User.id。您的表格将如下所示:

Option 3

    * User: id, name                    --- User data
    * Team: id, name                    --- Team data (name field can be dropped)
    * UserTeam: user_id, team_id        --- User belongs to Team
    * Test: id, description             --- Test definition
    * Invite: id, user_id, test_id      --- Invitation for User to make Test
    * TestDone: id, user_id, invite_id  --- TestDone after User accepted Invitation

因此所有团队也将是用户。

在重新阅读您关于这部分的描述后,我稍微更改了测试邀请。


示例脚本:

CREATE TABLE user
( id int NOT NULL AUTO_INCREMENT
, name VARCHAR(20) NOT NULL
, PRIMARY KEY (id)
) ;

CREATE TABLE team
( id int NOT NULL
, teamname VARCHAR(20) NOT NULL
, CONSTRAINT PK_team_id
    PRIMARY KEY (id)
, CONSTRAINT FK_team_id_TO_user_id
    FOREIGN KEY (id)
      REFERENCES user(id)
) ;

INSERT INTO user
VALUES
  (1, 'John')
, (2, 'George')
, (3, 'Mary' )
, (4, 'Team-1')  ;

SELECT * FROM user ;

| id | name   |
| 1  | John   |
| 2  | George | 
| 3  | Mary   |    
| 4  | Team-1 |       

INSERT INTO team
VALUES
 (4, 'Team-One') ;

SELECT * FROM team ;

| id | teamname |  
| 4  | Team-One | 

INSERT INTO team
VALUES
 (5, 'Team-Two') ;

> Cannot add or update a child row: a foreign key constraint fails
> (`test/team`, CONSTRAINT `FK_team_id_TO_user_id` FOREIGN KEY (`id`)
> REFERENCES `user` (`id`))

You could also have a Team defined as a special User with Team.id being both a Primary Key and a Foreign Key to User.id. You tables would look then like this:

Option 3

    * User: id, name                    --- User data
    * Team: id, name                    --- Team data (name field can be dropped)
    * UserTeam: user_id, team_id        --- User belongs to Team
    * Test: id, description             --- Test definition
    * Invite: id, user_id, test_id      --- Invitation for User to make Test
    * TestDone: id, user_id, invite_id  --- TestDone after User accepted Invitation

So all teams will be users too.

I slighly changed the test-invite after re-reading your description regarding this part.


Sample script:

CREATE TABLE user
( id int NOT NULL AUTO_INCREMENT
, name VARCHAR(20) NOT NULL
, PRIMARY KEY (id)
) ;

CREATE TABLE team
( id int NOT NULL
, teamname VARCHAR(20) NOT NULL
, CONSTRAINT PK_team_id
    PRIMARY KEY (id)
, CONSTRAINT FK_team_id_TO_user_id
    FOREIGN KEY (id)
      REFERENCES user(id)
) ;

INSERT INTO user
VALUES
  (1, 'John')
, (2, 'George')
, (3, 'Mary' )
, (4, 'Team-1')  ;

SELECT * FROM user ;

| id | name   |
| 1  | John   |
| 2  | George | 
| 3  | Mary   |    
| 4  | Team-1 |       

INSERT INTO team
VALUES
 (4, 'Team-One') ;

SELECT * FROM team ;

| id | teamname |  
| 4  | Team-One | 

INSERT INTO team
VALUES
 (5, 'Team-Two') ;

> Cannot add or update a child row: a foreign key constraint fails
> (`test/team`, CONSTRAINT `FK_team_id_TO_user_id` FOREIGN KEY (`id`)
> REFERENCES `user` (`id`))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文