Delete behavior clarification

From: Jim Menard (jim..o.com)
Date: Fri Dec 12 2003 - 10:54:08 EST

  • Next message: Andrus Adamchik: "Re: Delete behavior clarification"

    I've been reading the "Problems understanding delete behavior" thread
    in the archives and I would like to clarify my understanding. (I can't
    reply directly to the thread because of the spam block.) I'd like to
    talk through a couple of scenarios to make sure I understand what's
    happening and how to use delete rules properly.

    Does the delete rule take effect when the source gets deleted or when
    the target gets deleted? Based on Andrus's replies, I think it's the
    source.

    Using Mark's example,

            TestCategory +----<< TestGroup +----<< TestSubject

    TestSubject has a many-to-one relationship with TestGroup. If I set the
    TestGroup's toTestSubjectArray relationship's delete rule to "NULLIFY",
    then when I call context.deleteObject(subject) the "source" is the
    group and the "target" is the subject. (How is group the "source"? The
    group is not mentioned at all except indirectly because the subject has
    a FK to the group.)

    Here is where I am confused: there is nothing to nullify in the
    database. If we remove the subject record, it was the table with the
    foreign key back to the group table and therefore the removal of the
    subject record has no effect on the group table at all. In this case,
    does "NULLIFY" mean something to Cayenne (but not to the database
    data)?

    "CASCADE" would not make sense for TestGroup's toTestSubjectArray,
    correct?

    In the other direction, if I can set the TestSubject.toTestGroup
    relationship's delete rule to either "NULLIFY" or "CASCADE". You want
    "CASCADE" if you want all subjects to be deleted if the group is
    deleted, but you want "NULLIFY" if you want all subjects' FKs to be set
    to NULL when the group is delete. Is this correct?

    Thank you for your time and help.

    Jim

    -- 
    Jim Menard, jim..o.com, http://www.io.com/~jimm/
    "Master, does Emacs have the Buddha nature?" the novice asked.
    "I don't see why not. It's got bloody well everything else."
         -- John Fouhy
    



    This archive was generated by hypermail 2.0.0 : Fri Dec 12 2003 - 10:54:11 EST