In my PHP and psql application, I have large number of customers and service providers, both can login to the system, for login details we created a table USER but how can we map both CUSTOMER table and SERVICE_PROVIDER table in the USER table as foreign key. The structure Skeleton is
**CUSTOMER:**
id bigserial,
name character varying(100),
address character varying(350),
phone character varying(50),
etc....
**SERVICE_PROVIDER:**
id bigserial,
name character varying(100),
email character varying(100),
phno character varying(50),
first_esc character varying(100),
sec character varying(100),
etc
**USER**
id bigserial,
username character varying(100),
password character varying(100),
customer_type bigint
In USER Table column customer_type may either Customer or Service Provider
How to design the table structure....
Please help me
Thanking You Anju
What is needed is FKs from multiple other groups (subtypes) to (supertype) user.
Every table has a statement. The rows that make the statement true go in the table. Customers are users and service providers are users. So when CUSTOMER & SERVICE_PROVIDER (etc) say something is true about a person, USER says something about them.
// "customer [id] has ..."
CUSTOMER(id,...)
fk id references USER -- a customer is a user
// "service provider [id] has ..."
SERVICE_PROVIDER(id,....)
fk id references USER -- a service provider is a user
// "user [id] has ..."
USER(id,...)
See this .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.