Re: Referential integrity doesn't work? (Thanks a lot) - Mailing list pgsql-general

From Manuel Cano Muñoz
Subject Re: Referential integrity doesn't work? (Thanks a lot)
Date
Msg-id 1028252000.6257.67.camel@linux
Whole thread Raw
List pgsql-general
First thanks a lot for your help.

Now I'm not having 0 as a valid value in the ID fields (PRIMARY KEY,
FOREIGN, etc), that was an error of mine. The problem was the insert
whas inserting NULL values, and the trigger doesn't catch those. Now
I've changed the field to NOT NULL and all works fine.

Anyway I found a bit clumsy that referential integrity can't catch NULL
values, because forget to put a field NOT NULL is easy, and that almost
ruins referential integrity.

Say you have one table: create one (id serial primary key, char(5));
And another: create table two (id serial primary key, id_one int
reference one, description varchar(80));

This allows you to create "bogus" inserts like this:

insert into two (description) values ('Referential integrity
compromised');

Because of the id_one being NULL, you can insert all non-sense data into
your "integrity safe" tables.

Well, we all know a good database admin/designer/... should write ID
fields NOT NULL, but...  I would like the DBMS catching those for me.

Thanks a lot to everybody.




Manuel Cano

P.S.: i'm using  PostgreSQL 7.2



pgsql-general by date:

Previous
From: "Eliel Mamousette"
Date:
Subject: Any last hope advice?
Next
From: Justin Clift
Date:
Subject: Re: Any last hope advice?