(Beware, that might be one of the first academical questions on SQLA.)
In a longer comment dialogue between Breck and me on the following question, I raised the following question - now asking it here:
Is there a DRI action that is directed from the child to the parent table?
I.e. the action would be initiated if a row in a child table would be modified or deleted, and the referenced row in the parent table would be altered - exactly the other way around as in a typical DRI action (like ON DELETE CASCADE).
I know the answer is "No!" for SQL Anywhere (and I guess, for other DBMSs, too), but I would like to ask if something like that has ever been put into thought. Breck has invented the following syntax (making its future quite improbable):
Why would I want such a feature (not with that name, for sure!)?
Well, at times when doing data-modelling, I feel the need to introduce a reference between a so-called child table and a parent table where the parent table would be a weak entity in ER terms whereas the child table would be a strong entity. One might call the weak entity a "common attribute" of the strong entity.
In that scenario, it would be handy if one could express that the "parent-side" of a relationship would be influenced when no more child does reference that parent.
Today, I would use trigger code to delete the address if there's no more usage, and this feature might be uncommon enough to leave it that way. On the other hand, DRI actions have been introduced to prevent the usage of the more error-prone triggers for common tasks.
Other usages might be "code tables" where one might want to delete an entry when it isn't used anymore, or the tags used in SQLA: It seems that they get deleted (over night in some clean-up, methinks) when there is no more question tagged with them.
Any hints are highly appreciated:)
asked 12 Dec '09, 22:07
Sounds reasonable, even if I can't recall a situation where something like that would have been usefull. CHILD MANDATORY came to my mind as a tag for the parent, but that lead to this question: which side of the parent-to-child-relation should hold the constraint?
answered 14 Dec '09, 17:19