Database question
Ray Cote
rgacote at AppropriateSolutions.com
Tue Jan 24 10:24:01 EST 2006
>However, I want to restrict the member column by restricting the data
>in it to also exist *either* in machines.id *OR* in classes.id. The
>reason for this is that a class member can either be a machine or
>another class (think netgroups here). Does anyone know how to do
>this, or if it's even possible?
Triggers.
The design is not relational so you cannot do this with foreign keys.
Foreign keys enforce a column-to-column relationship.
You can do this with a trigger that looks in the two places.
Whenever you run into situations like this, it is always good to
step-back, consider the overall design to see how you ended up in
this situation, and see if a fully-relational design can be
implemented. However, when you really need it this way, triggers are
the way to go.
--Ray
--
Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.com
More information about the gnhlug-discuss
mailing list