sql server - SQL - Constraint between FK -
sql server - SQL - Constraint between FK -
i new in sql , have basic question.
in sql table having multiple fk pointing same foreign table, possible create constraint imposes rules between fk?
here's illustration of trying :
the table 1 contains names , gender of grouping of people name(pk), gender
the table 2 associates grouping of 4 people room number. room(pk), name (fk), name(fk), name(fk), name(fk)
how can constraint fk in sec table insure person of same gender associated room?
is there improve way deal such scenario?
thank you.
you can grouping on gender , if there more 1 row illustration if 2 names male , 2 names female, grouping on gendr homecoming 2 rows, in case raise error saying people same gender can allocated room.
sql sql-server foreign-keys foreign-key-relationship
Comments
Post a Comment