SQLite rowid as Foreign Key
I was really excited when I first learned about SQLite's rowid
feature.
There is however a downside to the automatic rowid
column: It can't be used as part of foreign keys. Quoting from the SQLite docs (emphasis is mine):
[…]. The parent key must be a named column or columns in the parent table, not the rowid.
Fixing this downside is easy: Just add an INTEGER PRIMARY KEY
column—it will get aliased to the rowid
column (See «ROWIDs and the INTEGER PRIMARY KEY»):
( id INTEGER PRIMARY KEY
, ...
);