Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database Table Design

I want to know you opinion and what should be the best approach for this case:

I have 2 table called: - clients; - suppliers;

I've create 2 pages for people to leave feedback about a client and for a supplier. With that in mind a created a table feedbacks.

Now the question is which approach should I choose:

1) Create one table called feedbacks with 2 foreign keys (clientid and supplierid). With this approach if they leave a feedback to the client then the FK supplierid would be empty.

2) create 2 tables called clientfeedbacks and suppliersfeedback. With this approach since each table would only have one FK then no FK would be empty.

Thank you.

like image 452
Yannick Avatar asked Aug 04 '26 22:08

Yannick


1 Answers

Why not just have one table called feedback, and then two separate join tables: client_feedback that maps client_id to feedback_id and then supplier_feedback that amps supplier_id to feedback_id? (has_many through in rails speak)

like image 103
Ben Taitelbaum Avatar answered Aug 08 '26 11:08

Ben Taitelbaum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!