Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: How to ensure only one of two sets of optional information?

Re: How to ensure only one of two sets of optional information?

From: --CELKO-- <joe.celko_at_northface.edu>
Date: 19 Dec 2003 15:59:24 -0800
Message-ID: <a264e7ea.0312191559.2c8329e1@posting.google.com>


CREATE TABLE Classes
(class_id INTEGER NOT NULL,

 subclass_type CHAR(1) NOT NULL

           CHECK(sub_class_type IN ('A', 'B')),  PRIMARY KEY (class_id, subclass_id),
 ... );

CREATE TABLE SubClass_A
(class_id INTEGER NOT NULL,

 sub_class_type CHAR(1) DEFAULT 'A' NOT NULL

           CHECK(sub_class_type = 'A'),
 FOREIGN KEY (class_id, subclass_id)
 REFERENCES Classes(class_id, subclass_id),   ... );

CREATE TABLE SubClass_B
(class_id INTEGER NOT NULL,

 sub_class_type CHAR(1) DEFAULT 'B' NOT NULL

           CHECK(sub_class_type = 'B'),
 FOREIGN KEY (class_id, subclass_id)
 REFERENCES Classes(class_id, subclass_id),   ... );

You can play games with inclusion rules in the CHECK() constriants, but this is the basic mutual exclusion pattern. Received on Fri Dec 19 2003 - 17:59:24 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US