New answers tagged

0

As mentioned by @MichaelKatz, commonly this is implemented with the primary key as a foreign key. In other words, it is a 1:0-1 relationship. But an interesting twist is to add a Type column, this identifies what type the base User row is so you know which rows to join onto. This becomes part of a composite primary key. The same key is used on the sub-tables,...


2

In these cases, I've always used the same PK value between Main Class and Subclass. This helps ensure a 1:1 relationship. Create table Users ( User_id int primary key, -- auto increment Username varchar(50) not null unique ); Create table students ( User_id int primary key references Users(User_id) ); Create table Supervisors ( User_id int primary ...


Top 50 recent answers are included