[Zope] constraint in postgres
Andrew Kenneth Milton
akm@mail.theinternet.com.au
Wed, 14 Feb 2001 23:46:38 +1000
+-------[ Fred Yankowski ]----------------------
| Isn't this a classic "referential integrity" case? If so, you could
| try this:
|
| create table country (id serial primary key, ...);
|
| create table address (id serial,
| country_id int4 references country, ...);
references country(id) more than likely, unless you have a unique country_id in country.
That is you don't need two fields with basicaly the same info, when you already have
a unique serial id which is the primary key.
This also stops you from inserting into address without a valid country, as
a bonus side effect.
--
Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton
The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 |
ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon
PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|