Note that there are some explanatory texts on larger screens.

plurals
  1. PODB : Circular dependency in the database
    primarykey
    data
    text
    <p><strong>EDIT:</strong> This is a <a href="https://stackoverflow.com/questions/1451553/cascading-deletes-causing-multiple-cascade-paths">duplicate</a> I didn't find it at first. </p> <p>I am building a web-site for user-groups event management. </p> <pre><code>Members : Name, Id Events : DateTime, Topic, OrganizerId (from FK to Members table) EventRegistrations : MemberId (FK), EventId (FK) </code></pre> <p><em>Description (redundant) :</em><br> A member can create and event, and becomes this event's organizer.<br> Any member can register for an event, and a record in EventRegistrations is created. </p> <p><strong>The Problem:</strong><br> When I create PK-FK dependency between the tables, I get an error saying: </p> <blockquote> <p>Introducing FOREIGN KEY constraint 'reg_evt_fk' on table 'eventregistrations' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.</p> </blockquote> <p><strong>Question:</strong><br> What is a good way to deal with this? I have two solutions to begin with: </p> <ol> <li>Introduce 4th (associating) table "Organizers : MemberId -> EventId". </li> <li>Disable CASCADE DELETE on one of the dependencies, and do check programmatically before DELETE operations. </li> </ol> <p>I'm looking for suggestions or a feedback on the above. Extra explanations/comments are appreciated.</p> <p><em>Note</em>: DB is SQL Server 2008, but it shouldn't matter, I think.</p> <p><strong>EDIT:</strong> Suppose deleting an event <em>IS</em> required behavior (example is simplified).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload