Answer the question
In order to leave comments, you need to log in
Architecture of relationships between tables in a database?
I build a relationship between tables. business logic is. There is an event (event table), from two to infinity users can take part in it (users table). After the end of the event, each of the participants can leave a review for another participant (feedbacks table) with a link to this event. So there are 3 tables. I have defined the links as follows:
events:
id
....
users:
id
...
feedbacks:
id
ivent_id(OnetoOne to events)
from_id(ForeignKey to users)
to_id(ForeignKey to users)
Answer the question
In order to leave comments, you need to log in
events:
id (PK)
....
users:
id (PK)
...
event_users
event_id (PK, FK to events)
user_id (PK, FK to users)
feedbacks:
id (PK)
event_id (FK to events)
user_id_from (FK to users)
user_id_to (FK to users)
idx_unique (event_id, user_id_from, user_id_to) - уникальный индекс
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question