I am very confused and I have read a lot on internet & SO but I cant figure out. In this design, scalability is an important task for me.
I am making a portal where people can offer to sell their food or can go to this portal to buy food.
I am thinking about following 3 options:
I created a User table mostly for security because I dont want secret data to reside in Customer or Cook table.
Problem is that a Cook can also be a customer.
I am thinking of approach 1. How do I model it. Do I use recursive approach. Recursive approach works with Employee and Manager idea (standard textbook example) but it seems strange here.
In approach 2, I use 1 table and I do not differentiate between cook and customer. Not making this distinct, seems like a bad idea somehow.
Approach 3 is possible but I cant think in my mind, how it can work
A user table is like this:
A customer table is like this:
I recommend using the three table approach to separate data specific to each role.
The relationships between User and Customer (or User and Cook) are one-to-zero-or-one. So for each User there may be a Customer or a Cook record, or both if the User fulfils both roles.
Diagram made here: https://app.quickdatabasediagrams.com/#/schema/t_JngpUcm0-w_dbnW3FzsA [Disclaimer: I work for QuickDatabaseDiagrams]
You can create one more column in user table "userType"[buyer/seller/both].This will help to know current user is acting as a buyer , seller or both. This will help to model system flow as well .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With