Search Postgresql Archives

REFERENCES ignored when there is inheritance?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a table to store localization information:

CREATE TABLE Localization (
...
 zipcode TEXT NOT NULL,
...
 country INTEGER REFERENCES Countries (id) NOT NULL

The table Countries is like:

CREATE TABLE Countries (
 id SERIAL UNIQUE,
 name TEXT UNIQUE NOT NULL,
 code CHAR(2) UNIQUE NOT NULL);

And a table Contacts_short which inherits from it so all the Contacts
have localization information:

CREATE TABLE Contacts_short (
...
INHERITS (Localization, Objects) WITHOUT OIDS;

I have 240 countries in the database. Because of a programming error,
contacts were entered with a country > 240. I thought that the
"REFERENCES Countries (id)" should have prevented it. Is it because of
inheritance?

PostgreSQL 7.4.7

Example:

registry=> SELECT max(id) FROM Countries;
 max 
-----
 240
(1 row)

registry=> SELECT count(*) FROM Contacts_short WHERE country > 240;
 count 
-------
    84
(1 row)

To me, the last figure should have been zero.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux