I am building a database that includes the following tables:
pages
users
A particular user can access (or is associated with) a page with one of the following roles (permissions):
- Owner
- Administrator
- Editor
What will be the best approach in this kind of situation? Either to setup join tables like this:
owners
(page_id
,user_id
)administrators
(page_id
,user_id
)editors
(page_id
,user_id
)
Or using a single join table:
pages_users
(page_id
,user_id
,role
)
Also, if the second approach is preferable, should role
attribute be a string
(such as 'owner'
, 'administrator'
, or 'editor'
) or something like role_id
and the roles defined in a separate table as follows:
roles
(id
,name
)
If there's a completely different approach which fits the need in a more appropriate manner, please let me know.
Also, is there any special name for this type of relationship(s) in database jargon? I am unable to craft the question's title right, edits are welcome.
Thank you for your answers