Eine Einführung in


CREATE TABLE with a foreign key


A foreign key references is where one field "links" to another table.

The database will maintain referential integrity - this means that there must be a corresponding record in the other table - in this example each track must be on an album that exists in the album table.

The field (or fields) linked to must be unique - usually the other field is the primary key of the other table.

In this example we store details of tracks on albums - we need to use three columns to get a unique key - each album may have more than one disk - each disk will have tracks numbered 1, 2, 3...

Execute tidy up code silently

Specific to SQLite
The relationship between the tables is not enforced. Even when the album table is empty we can create a record in the track table: