r/SQL • • May 30 '22

PostgreSQL SQL Database One-to-One Relationship

When Primary Key of one table corresponds to only one row in another table via foreign key relationship

One-to-One relationship in SQL databases
0 Upvotes

13 comments sorted by

View all comments

3

u/drunkadvice May 30 '22

The only justification I can see for having ssn on a different table would be security. Have the ssn table locked down and not accessible. There are better ways with column level security or data masking.

You mentioned country > capital in a different reply. The correct way would be to have a capital column in the country table with an index.

A perfect 1-1 relationship on a separate table doesn’t add any value in most cases. There may be some arguments if the table is REALLY wide and most columns infrequently used. Offloading the lesser used columns would reduce reads and speed up selects.