Search code examples
postgresqlentity-relationshipreferential-integrity

Referential cycle: ON DELETE CASCADE?


enter image description here

If "predmet" is a FK to "predmeti", and "nositelj" is a FK to "nastavnici",

what will happen if I specify ON DELETE CASCADE to both foreign keys and delete one of the entities? Would it produce an error?

Edit: I'm using the latest version of PostgreSQL.


Solution

  • Read manual for your RDBMS (you have not specified it). Typically circular cascade forbidden - you will get an error on create.

    UPDATED: try http://sqlfiddle.com/#!1/24df4/2/0 It seems it is not forbidden - remove recursively.

    Someone very kind minused me, because i have fixed the tags and it makes my post incorrect)