Sample Header Ad - 728x90

How to enforce entity existence across N-tables - postgres

1 vote
2 answers
81 views
Let's say we decided to split user table in two, one will have data related to authentication, another basic user description:
user_table
user_id | name
1       | Max
2       | Alex
3       | Should not be possible
auth_table
user_id | email   | password
1       | m@m.com | 123
2       | a@a.com | 321
4       | s@s.com | Should not be possible
Is it possible to enforce existence of the same user_id? Basically both tables should have exactly same number of rows and each row should have a match in both tables.
Asked by ZiiMakc (135 rep)
Jul 23, 2023, 06:24 PM
Last activity: Jul 25, 2023, 02:48 PM