简体   繁体   中英

Database schema: User Team administration

I have users , who are members of many teams through a membership table. Each team has one administrator.

My question is:

Should the admin column be a boolean in the membership table, or an integer (id of user) in the team table?

Most simple is, yes: in membership table as that is the link between a User and a Team. In that case you would be more flexible to add for example 2 administrators. The other way around is also a valid one, considering it secures to have explicitly 1 administrator.

The disadvantage is for example that there is a relation which you should enforce so admin_id always links to a User which is really a member of the Team. So on delete you should check whether this admin is really still available.

A bit further thinking: Consider whether you have multiple roles, if that's the case you might use a more complex but flexible solution like ACL's and things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM