[Ur] solution to the DB chicken and egg problem?

Marko Schütz Schmuck markoschuetz at googlemail.com
Sun Apr 2 08:35:29 EDT 2017


If I have tables

table chicken : { Id : int, Egg : int }
      PRIMARY KEY (Id),
      CONSTRAINT egg FOREIGN KEY Egg REFERENCES egg(Id)

table egg : { Id : int, Chicken : int }
      PRIMARY KEY (Id),
      CONSTRAINT chicken FOREIGN KEY Chicken REFERENCES chicken(Id)

Outside of Ur/Web this would be solved by setting the constraints
DEFERRABLE INITIALLY DEFERRED and do the INSERTs pairwise inside a
single transaction.

I doubt that there currently is a way to do this in Ur/Web since there
is neither a way to specify DEFERRABLE INITIALLY DEFERRED nor a way to
explicitly form transactions.

Would it be enough to introduce an operator

dml_sequence : dml -> dml -> dml

allowing two dml statements to be composed and run in a single
transaction together with exposing DEFERRABLE INITIALLY DEFERRED at
the Ur/Web language level?

Best regards,

Marko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP Digital Signature
URL: <http://www.impredicative.com/pipermail/ur/attachments/20170402/dc6b11b7/attachment.sig>


More information about the Ur mailing list