SQLite Forum

Help with foreign key
Login
Each table has a primary key which makes a unique identifier for each row in that table. The reference for a foreign key means that the value in one table refers to the row in the other table identified by the primary key. But you have to tie the two values together, as:
<code>
CREATE TABLE artist(
  artistid INTEGER PRIMARY KEY,
  artistname TEXT );
CREATE TABLE track(
  trackid INTEGER PRIMARY KEY,
  trackname TEXT,
  trackartist INTEGER REFERENCES artist(artistid) );
</code>
If you had used the same name of the column in both tables, you could leave out the foreign key column name.