2021-05-31

How to refer with a Foreign Key to a Primary key that has a specific value in some columns?

Let's say I have a site user table and they have an account type (client, master, and so on).

Create table user_info(
userId int not null,
userPassword varchar(60),
userEmail varchar(30),
userLogin varchar(25),
userType enum ('client','master','administrator'),
Constraint Pk_userId Primary Key(userId));

And there is a table that describes the masters, in which the identifier refers only to those identifiers in the users table that are of the master type.

Create table masters(
masterId int not null,
serviceId int,
Constraint Fk_masterId Foreign Key(masterId)references user_info(userId));

How can I do this and is it possible?



from Recent Questions - Stack Overflow https://ift.tt/3hZudyW
https://ift.tt/eA8V8J

No comments:

Post a Comment