用户测试/组测试的架构
我有一个用户可以执行测试的用例。这是基于邀请的。因此,管理员可以向用户发送邀请以执行选定的测试。还可以创建一个由多个用户组成的团队,并向团队的所有用户发送邀请以执行该团队的测试。
创建这些模型有多种选择,但我不确定什么是最好的方法(或者甚至可能有替代方法)。
选项 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我会选择你的第二个选择。
不过,您可能还想研究第三个选项。它可以存储发送给多个团队和用户的邀请:
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:
您还可以将
Team
定义为特殊的User
,其中Team.id
既是Primary Key
又是外键
到User.id
。您的表格将如下所示:因此所有团队也将是用户。
在重新阅读您关于这部分的描述后,我稍微更改了测试邀请。
示例脚本:
You could also have a
Team
defined as a specialUser
withTeam.id
being both aPrimary Key
and aForeign Key
toUser.id
. You tables would look then like this:So all teams will be users too.
I slighly changed the test-invite after re-reading your description regarding this part.
Sample script: