constraint via selection

From: Horst Herb <hherb(at)malleenet(dot)net(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: constraint via selection
Date: 2001-11-17 12:18:22
Message-ID: 20011117121312.5700.qmail@gnumed.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear list,

I have two simplified tables "country" and "location":

create table country (
code char(2) primary key,
name varchar(60)
);

create table location (
id serial primary key,
country char(2) references country(code),
[...]
);

Location should have a foreign key to country.code, but for performance &
ressource reasons it would be much better to have a copy of the country
code in location.country rather than a foreign key:

create table location (
id serial primary key,
country char(2) check ...
);

What would the most efficient formulation of the "check" constraint be in
this case?

Horst

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Horst Herb 2001-11-17 13:00:57 Re: constraint via selection
Previous Message Gurudutt 2001-11-17 04:10:58 Re: [SQL] Joins!!