[mod:sql-queries.txt] Modify foreign keys

Foreign keys to all required tables are added and modified according to modified database.