View previous topic :: View next topic
|
Author |
Message |
ntmartins
New User
Joined: 03 Mar 2008 Posts: 11 Location: Lisboa, Portugal
|
|
|
|
The zoo has a business rule that a food cannot be deleted if that food is the only food eaten by any animal. Can this rule be enforced by referential integrity (foreign key) constraints? (In other words, can referential integrity keep us from deleting a food from LEGAL_FOOD if that food occurs in the only species-food row for a particular species?) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
can referential integrity keep us from deleting a food from LEGAL_FOOD if that food occurs in the only species-food row for a particular species |
I believe not. Referential integrity could prevent deletion if this food was eaten by some animal, but not if it is the only food eaten by an animal.
The deletion validation would go something like determining a list of animals who ate this food, then determining if this food was the only food eaten by each animal in the list. Not a feature/function of referential integrity. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
I think it could be enforced by a trigger. |
|
Back to top |
|
|
|