Beginner video on Foreign Keys in relational databases. Foreign keys allow for "lookups" between two tables. To ensure that these "lookups" are valid, we can enforce referential integrity, which makes sure that all foreign key values actually exist in the primary key table. Although referential integrity is specified as a constraint on the foreign key table, both tables involved check data changing operations to ensure all foreign key values are always valid. Primary Keys are always UNIQUE and NOT NULL, but Foreign Keys are generally not UNIQUE, and can be NULL.
See the full code here: http://douglaskline.blogspot.com/2018...