on-internet
← Community

SQLite composite key (2 foreign keys) Link table

Stack Overflow ·

I've read the BNF grammar for the SQLite CREATE TABLE command found here: http://www.sqlite.org/lang_createtable.html. I was wondering how to create a link table. Let's say I have two tables: houses and electrical_items. I want to create a link table to have the house_id and the item_id as a composite key. However, SQLite doesn't appear to allow a primary key to be a foreign key? N.B. I want a third field pap_tested which stores the date the electrical item in the house was pap_tested. This linking table via composite primary key seems like the best approach.

Comments

Sign in or sign up to comment and upvote.

No comments yet.