Table.Foreign_key
Foreign keys.
Foreign keys represent SQL FOREIGN KEY constraints on a table.
We use the parent-child terminology of SQLite. The parent table is the table that the foreign key refers to. The child table is the table making the reference.
type action = [
|
`Set_null
The child key becomes NULL.
*)|
`Set_default
The child key is set to the default.
*)|
`Cascade
The row with the child key gets deleted or updated.
*)|
`Restrict
The parent key cannot be deleted or updated.
*) ]
The type for foreign key actions on parent delete or updates.
This is the parent table and the columns that are referenced within. Use `Self
to refer to table being defined.
Note. For now the module does not check that the list of columns actually belong the parent table. Do not rely on this Invalid_argument
may be raised in the future on v
.
type 'r t = 'r foreign_key
The type for foreign keys.
val v :
?on_delete:action ->
?on_update:action ->
cols:'r Col.v list ->
parent:parent ->
unit ->
'r foreign_key
v ?on_delete ?on_update ~cols ~parent ()
is a foreign key with given arguments. See accessors for semantics.
val cols : 'r foreign_key -> 'r Col.v list
cols fk
are the child table columns of fk
.
val parent : 'r foreign_key -> parent
parent fk
is the parent table of fk
.
val on_delete : 'r foreign_key -> action option
on_delete fk
is the action taken whenever the parent key of fk
is deleted.
val on_update : 'r foreign_key -> action option
on_update fk
is the action taken whenever the parent key of fk
is updated.