When generating SQL code, the resulting code will be a function which takes some parameters, and performs the restoration of the invariant.
The question is which parameters it should take. There seems to be two forms of tables that we may need to insert/delete into: tables for relations of type I[A] for some A, and subsets of V[A,B] for some A, B. Operationally, identity relations are represented as tables with a unique ID, and multiple fields. The issue is complicated slightly because of subtyping in Ampersand - some relations are represented by the same table, being subsets of some relation which is the upper bound of several other relations. Rows in the table representing entries in a subtype relation contain nulls - hopefully MySql can deal with this automatically. The representation for relations of the form [A,B] is much simpler - it is a table with two columns, one called src and the other tgt, and the values are the unique IDs of the rows in the identity relations corresponding to A and B.
When generating SQL code, the resulting code will be a function which takes some parameters, and performs the restoration of the invariant.
The question is which parameters it should take. There seems to be two forms of tables that we may need to insert/delete into: tables for relations of type
I[A]
for someA
, and subsets ofV[A,B]
for someA
,B
. Operationally, identity relations are represented as tables with a unique ID, and multiple fields. The issue is complicated slightly because of subtyping in Ampersand - some relations are represented by the same table, being subsets of some relation which is the upper bound of several other relations. Rows in the table representing entries in a subtype relation containnull
s - hopefully MySql can deal with this automatically. The representation for relations of the form[A,B]
is much simpler - it is a table with two columns, one calledsrc
and the othertgt
, and the values are the unique IDs of the rows in the identity relations corresponding toA
andB
.