I’ve got two tables.
One is ‘Corporations’ (e.g., one record is for Taco Bell). The index and PK for this table is named ‘Id’.
I’ve got another table: ‘Branches’ (e.g., one record is for Los Angeles). The Branch table has a column named ‘Corporation’. This column should only accept an ‘Id’ value that corresponds with an ‘Id’ in the ‘Corporations’ table.
How do I enforce this? Do I add a constraint? How do I do that?
If I’m barking up the wrong tree, how do I define this relationship between Corporations and Branches?
Add a FOREIGN KEY to Branches that references Corporations.
i.e. in the CREATE TABLE for Branches: