| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: super type & sub type, interested too
On Wed, 06 Nov 2002 18:26:25 +0100, Michael Gast wrote:
[...]
>
> I assume you are using the doc_id in both, the supertype and your
> subtype tables. In addition i assume you have foreign keys from each
> subtype to your supertype.
>
> This given:
> 1. Insert your row in the supertype table.
> 2. Insert your row in the subtype table.
>
> Additional hint: If you have distinct subtypes you should add insert and
> update triggers on each subtype table to ensure that a primary key value
> you want to insert in one subtype table is not used in another subtype
> table.
I assume the discussion is regarding normal parent and child tables (and not some special structured types or similar). I.e. something like (pls ignore typos, to long identifiers etc):
One way of validating super/sub type is as you point out via triggers. Another one which I have been thinking about would be to add a unique constraint in the super table, and use that as foreign key in the subtable. Together with a check constraint in the subtable that should also do the trick. I.e.:
create table shipping_document (
doc_id integer not null,
doc_type_id integer not null,
shp_id integer,
Any thoughts on benefits/drawbacks with these two methods respectively?
/Lennart Received on Wed Nov 06 2002 - 14:43:30 CST
![]() |
![]() |