質問

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top