Skip to content
Advertisement

How to use multiple foreign keys in one table in sqlite?

JavaScript

I believe it’s most likely to be something within the first foreign key reference.

Advertisement

Answer

Either move all the FOREIGN KEY definitions at the end of the statement:

JavaScript

or, define each foreign key right after the definition of each column without the FOREIGN KEY keywords:

JavaScript

See the demo.

Note that there is no string data type in SQLite.
I changed it to TEXT.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement