Overview: within this tutorial, you will understand guidelines for using the SQLite foreign key constraint to apply the connections between related tables.
SQLite foreign key constraint assistance
SQLite features recognized mysterious key restriction since type 3.6.19. The SQLite collection must staying gathered with neither SQLITE_OMIT_FOREIGN_KEY nor SQLITE_OMIT_TRIGGER.
To check whether your existing model of SQLite supporting mysterious secret constraints or otherwise not, you might use below command.
The order comes back an integer importance: 1: enable, 0: impaired. In the event the command earnings almost nothing, this means that your SQLite type donat supporting mysterious trick constraints.
If your SQLite room is created with mysterious secret restriction support, the applying will use the PRAGMA foreign_keys demand to allow or immobilize foreign principal constraints at runtime.
Summary of the SQLite overseas principal restrictions
Letas focus on two tables: vendors and supplier_groups :
Let’s assume that each dealer is assigned to lone one company team. And every one dealer crowd own zero or a lot of dealers. The relationship between supplier_groups and dealers information is actually one-to-many. Put simply, for every row through the dealers counter, there certainly is a corresponding row within the supplier_groups stand.
At this time, it is impossible keep you from including a-row on the suppliers stand without a related row in supplier_groups dining table.
As well, you can take out a row through the supplier_groups table without deleting or changing the related rows inside the distributors desk. (tovább…)