473,379 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 2689
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
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
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
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
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
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
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
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
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
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.