Primary Keys and Foreign Keys
This kind of cross-reference is so important that SQL provides syntax to allow automatic “integrity checks” and allow optimizations.
We can change the abbrev column to be a primary key of the departments table by the following SQL command:
ALTER TABLE departments ADD PRIMARY KEY (abbrev)
We add a constraint that any allowed value in the dept column of students must be a valid primary key in the departments table by the SQL command:
ALTER TABLE students ADD FOREIGN KEY (dept)
REFERENCES departments (abbrev)