Answer the question
In order to leave comments, you need to log in
When to use a foreign key and when a literal notation?
When to use a link pointing to another table, and when to write it as a literal?
For example rbac:
There is a table users (user):
id | login
And there is a table of user roles (role):
id | name
There is also a table of assignments of these roles (role_assignment):
id | role_id*** | user_id
I met different options, somewhere role_id is a foreign key indicating an entry in role, and somewhere there the role name is simply written down
Why and in what cases - it is necessary to do not a foreign key, and to write down a name?
Answer the question
In order to leave comments, you need to log in
Text - when the role has a separate semantic load, for example, a role in a film.
Code from a linked table - when the role defines common functionality, such as access level.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question