Re: Conditional Relationships ?

From: --CELKO-- <71062.1056_at_compuserve.com>
Date: 28 Dec 2002 21:11:44 -0800
Message-ID: <c0d87ec0.0212282111.35e1b34e_at_posting.google.com>


>> I'm curious as to how one would go about setting up and enforcing a
Conditional Relationship. <<

Try a better example; a student is either a foreign students or a domestic student. Unlike your orders and order details example, the two cases are clearly not related to each other.

In Standard SQL-92, you would use a CREATE ASSERTION statement, which is like CHECK() constraint at the schema level. Here is one way

CREATE ASSERTION StudentClassification
CHECK (((SELECT student_nbr FROM DomesticStudents

        UNION ALL 
        SELECT student_nbr FROM ForeignStudents)
        EXCEPT 
        SELECT student_nbr FROM Students) IS NULL);
Received on Sun Dec 29 2002 - 06:11:44 CET

Original text of this message