pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Horst Herb <hherb@malleenet.net.au>
To: pgsql-sql@postgresql.org
Subject: constraint via selection
Date: Sat, 17 Nov 2001 23:18:22 +1100
Message-ID: <20011117121312.5700.qmail@gnumed.dhs.org> (raw)

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



view thread (4+ messages)  latest in thread

Message-ID: <20011117121312.5700.qmail@gnumed.dhs.org>
Permalink:  ../20011117121312.5700.qmail@gnumed.dhs.org/
Also on:    postgresql.org/message-id/20011117121312.5700.qmail@gnumed.dhs.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hherb@malleenet.net.au
  Subject: Re: constraint via selection
  In-Reply-To: <20011117121312.5700.qmail@gnumed.dhs.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox