Re:Postgres 15 improves UNIQUE and NULL
by Beltalowda on Monday July 11, 2022 @05:25AM
(#32053941)
It's a 0-1:1 relationship, so you'd have columns like "name", "email", "car", etc. on the employees table, and "car" might have a unique index (which is probably an ID referencing a "cars" table).
Since employees can only have one car and since a car can only be used by one employee, an unique index is fine, but there may be 20 people that don't have a car so you don't want NULL values to be unique.
Of course there are always ways to work around this, but this is the general idea.
Since employees can only have one car and since a car can only be used by one employee, an unique index is fine, but there may be 20 people that don't have a car so you don't want NULL values to be unique.
Of course there are always ways to work around this, but this is the general idea.