aeric, thanks!
Will cascading updates and deletions of records work?
The question arose because of the following:
I created two linked tables in the third-party program "Navicat Premium". When adding a new record to the subordinate table with a key that is not in the main table, no exception is thrown. Why?
So I am trying to create tables in code.
Sub FillDb
Dim db As SQL
File.Copy(File.DirAssets,"empty.db",File.DirApp,"my.db")
db.InitializeSQLite(File.DirApp, "my.db", True)
db.ExecNonQuery("CREATE TABLE artist(artistid INTEGER PRIMARY KEY,artistname TEXT)")
db.ExecNonQuery("CREATE TABLE track(trackname TEXT,trackartist INTEGER REFERENCES artist(artistid) ON UPDATE CASCADE ON DELETE CASCADE)")
db.ExecNonQuery("INSERT INTO track (trackname, trackartist) VALUES ('abc',2)")
End Sub
When adding an entry to the track table, I figured an exception should be thrown, since there is no entry with key 2 in the artist table. But there is no exclusion.
SQLite doesn't work like that?
" Assuming the library is compiled with foreign key constraints enabled, it must still be enabled by the application at runtime, using the PRAGMA foreign_keys command. For example:
Thank you, I understand that.
This is a line from code when I didn't create the database in code. I have a lot of tables with links, so I create an empty database in a third-party program, it's easier