473,507 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Integrity constraints with type inheritance

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.
Jul 19 '05 #1
1 2693
By creating your table my_table as of type base_typ, you stop yourself
from being able to apply constraints referring to attributes of d1_typ
only. According to Oracle (and any other OO languages), your variable
"f2" does not even exist in the context of my_table. I therefore don't
think that what you're trying to achieve is possible. I know it's not
practical, but you'll have to define your tables of the type at the
bottom of the hierarchy tree if you want to define constraints
accessing variables only at the bottom of the tree. If you constantly
expand on your hierarchical tree, go back to the drawing board and
re-think your design approach.

Daniel
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2542
by: Nagib Abi Fadel | last post by:
HI, let's say i have a tansaction table called TRANSACTION (transaction_id,amount,type,type_id) Let's say a transaction can have multiple types: TYPE1, TYPE2 for example. EACH type has his...
4
15797
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
6
2032
by: Christian Rank | last post by:
Hello, I came across the following problem with integrity constraints and PL/pgSQL (PostgreSQL version used: 7.4.2): I defined the following tables, constraints and data: create table a (n...
6
2475
by: Greg Stark | last post by:
There's another poster complaining about referential integrity checks causing deadlocks. Unfortunately I've deleted the message so this response (and the archives aren't responding) isn't going to...
7
2436
by: Jimmie H. Apsey | last post by:
Referential Integrity on one of our production tables seems to have been lost. I am running Postgres 7.1.3 embedded within Red Hat kernel-2.4.9-e.49. Within that I have a table with referential...
4
1673
by: Ian Lazarus | last post by:
Why are constraints needed? In C++, an attempt to use a non-existing method will cause a compiler error. Isn't that true in C# also?
80
7797
by: Andrew R | last post by:
Hi I'm creating a series of forms, each with with around 15-20 text boxes. The text boxes will show data from tables, but are unbound to make them more flexible. I want the form to be used...
2
1363
by: njames | last post by:
There are two doubts regarding integrity constraints : 1) Can the constraints "NOT NULL" and "DEFAULT" be assigned at table level ? i have tried using the syntax of CHECK constraint at table...
1
229
by: Yan Pujante | last post by:
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
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.