constraint via selection - Mailing list pgsql-sql

From Horst Herb
Subject constraint via selection
Date
Msg-id 20011117121312.5700.qmail@gnumed.dhs.org
Whole thread Raw
Responses Re: constraint via selection  (Horst Herb <hherb@malleenet.net.au>)
List 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


pgsql-sql by date:

Previous
From: Gurudutt
Date:
Subject: Re: Joins!!
Next
From: Horst Herb
Date:
Subject: Re: constraint via selection