Foreign keys not working
The problem is in the FK constraint, because they are not enabled. I am using DB Browser for SQLite, so you only have to go here in order to enable it:


Then just check that Foreign Keys is enabled: