需要帮助o创建表结构sql?

时间:2021-10-17 19:22:02

I have to create following table structure for a group.

我必须为组创建以下表结构。

1 member can join many groups

1名成员可以加入许多团体

1 group can have only 1 owner member

1组只能拥有1个所有者

need to design these two tables member and group?

需要设计这两个表成员和组?

i tried like

我尝试过

MemberTable

Mid(PK) Mname MAddress 
1m      aaa   IND
2m      bbb   UK

GroupTable

   Gid(PK) Mid(FK) Gname 
     1g       1m     GROUP1
     2g       1m     GROUP2
     3g       2m     GROUP3

is this a correct approach or should i create a 3rd table?

这是一个正确的方法还是我应该创建第三个表?

1 个解决方案

#1


0  

table Member

id, memberName

table Group

id, groupName, OwnerId

with a FK from OwnerId to table member(id)

从OwnerId到表成员(id)的FK

relational table MembersxGroup

关系表MembersxGroup

memberId, groupId

with both FKs from memberId and groupId to respective tables and a unique non clustered index covering both columns

使用来自memberId和groupId的FK到相应的表以及覆盖两列的唯一非聚簇索引

#1


0  

table Member

id, memberName

table Group

id, groupName, OwnerId

with a FK from OwnerId to table member(id)

从OwnerId到表成员(id)的FK

relational table MembersxGroup

关系表MembersxGroup

memberId, groupId

with both FKs from memberId and groupId to respective tables and a unique non clustered index covering both columns

使用来自memberId和groupId的FK到相应的表以及覆盖两列的唯一非聚簇索引