Answer the question
In order to leave comments, you need to log in
How to properly build relationships and design tables?
Hello! Need advice:
There is a table of users
Users
-id
-first_name
-last_name
Company
-id
-name
-slug
-logo
Role
-id
-name
Comment
-id
-company_id (id компании на которую отзыв)
-user_id (id пользователя кто оставил коммент)
-text
Answer the question
In order to leave comments, you need to log in
We need at least two more tables.
The first describes a many-to-many relationship between a company and a role. Indeed, in different companies there may be a different set of roles - somewhere there is an auditor, but somewhere not, for example ...
The second describes a many-to-many relationship between the user and the first table.
Together they define what specific role in a particular company a particular user has.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question