Frage

I have table 'users'. Users can have roles - 'client' and 'employee'. Clients can give employees feedback (rating). I am not sure, how to implement it correctly, since clients and employees are one entity in schema (users).

I thought about something like this:

a img

So, if a user has role 'client' then he will have feedback through 'given_feedback', and if 'employee', then through 'received_feedback'? Is it appropriate way to do it?

It is alike to this question: Database Design - Linking two users though in my case it is important to know who gave the feedback and who received it.

War es hilfreich?

Lösung

I would do something like this:

users

id
first_name 
last_name 
email 
role_id
etc..

feedback_users

id
user_id
given_feedback - a value that tells if it's given (1) or recieved feedback (0))
feedback_text

roles

id
name

(two rows with client and employee)

Relations between above tables:

users.id - feedback_users.id (1 to many)
users.role_id - roles.id (many to 1) //given that a user can only have one role
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top