Integrity constraints with type inheritance

From: Yan Pujante <ypujante_at_linkedin.com>
Date: 8 Sep 2003 09:16:28 -0700
Message-ID: <401833c7.0309080816.2bef078e_at_posting.google.com>


I am having the following issue that I am not sure how to solve:

I have a base type:

create type base_typ as object (
id number,
f1 number) not final;
/

and a derived one

create type d1_typ under base_typ (
f2 number);
/

Now I create a table of the base type

create table my_table of base_typ;

From the oracle documentation, a type doesn't have integrity constraint but you can add some on the table, so for example I can say:

alter table my_table modify f1 constraint my_table_n1 not null;

Using substitutability, it is possible to do insert into my_table values (d1_typ(1, 2, 3));

How can I put a constraint on the table saying for example that f2 > f1 ? I cannot define it at the type level and I don't know how to define it at the table level since it is a table of 'base_typ'.

I know that if I create a table of type d1_typ then I can simply define the constraint, but that is not the point... there may be d2_typ, d3_typ... in the future and that would be impracticle to create that many tables (especially if there is another table that references my_table).

Thanks for any help. Received on Mon Sep 08 2003 - 18:16:28 CEST

Original text of this message