Referential Integrity thru Views

Started by Kapil Tilwaniover 24 years ago3 messagesgeneral
Jump to latest
#1Kapil Tilwani
karan_pg_2@yahoo.com

Hi,
Right now, I am enforcing uniqueness in three different tables (Supplier, Customer, Ledger) thru the front-end by checking thru a Union Query. Is it possible to enforce such a uniquenessthru in the DB.

Irrespective of the above, is it possible to have a foreign key check in this (???)

Thanx,
Kapil

#2GH
grasshacker@over-yonder.net
In reply to: Kapil Tilwani (#1)
Re: Referential Integrity thru Views

On Fri, Aug 03, 2001 at 11:35:25PM +0530, some SMTP stream spewed forth:

Hi,
Right now, I am enforcing uniqueness in three different tables (Supplier, Customer, Ledger) thru the front-end by checking thru a Union Query. Is it possible to enforce such a uniquenessthru in the DB.

Irrespective of the above, is it possible to have a foreign key check in this (???)

Yes.

If you mean supporting uniqueness in views, you would have to enforce
uniqueness on the underlying tables.
You can do this using "create table ... primary key" and "references"
as well as foreign key triggers.

The documentation is actually quite good on these, IIRC.

Thanx,
Kapil

gh
--
What, no one sings along with Ricky Martin anymore?
My kid sister does (but then, she prefers pico to vi ...)
-- Suresh Ramasubramanian, alt.sysadmin.recovery

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Kapil Tilwani (#1)
Re: Referential Integrity thru Views

On Fri, 3 Aug 2001, Kapil Tilwani wrote:

Right now, I am enforcing uniqueness in three different tables
(Supplier, Customer, Ledger) thru the front-end by checking thru a
Union Query. Is it possible to enforce such a uniquenessthru in the
DB.

Do you mean you want uniqueness of ids across the three tables so that
Customer's id never duplicates a Supplier id for example? If you're
using serial integer ids now (or a sequence), I'd suggest setting them all
to use the same sequence generator, barring wraparound, that should
guarantee uniqueness.

Irrespective of the above, is it possible to have a foreign
key check in this (???)

It depends on what you mean. As another poster said, if you mean
between those three tables individually, yes. If you mean a foreign key
to a view itself, like a union view, no.