A foreign key is a column that references the primary key of a row in a foreign table. For instance, a EnrolledCourses table might have two foreign keys referencing Students.ID and Courses.ID, respectively.

One way foreign keys maintain data integrity is that it helps prevent accidental deletions, e.g. by specifying ON DELETE RESTRICT, which is often the default. It can also facilitate recursively deleting all related resources of a row, e.g. by specifying ON DELETE CASCADE, etc.