foreign key help

From: Dale Sykora <dalen(at)czexan(dot)net>
To: PgSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: foreign key help
Date: 2005-03-16 22:35:31
Message-ID: 4238B4B3.8060904@czexan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am building a database that has about 20 fields in various tables that
I would like to constrain to a small group (<=5) of choices. Rather
that refer to 20 seperate tables, I would like to refer to 1 table that
contained category and choice fields.

for example

choices table

category | choice
-----------------
color | red
color | green
size | small
size | big
shape | circle
shape | square

item table

item | shape
-----------------
box | constrain to choices(choice) where category='shape'

Is there an easy way to do this, or is it better to have many
choices_category tables?

Thanks,

Dale

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew B. Lundgren 2005-03-16 23:45:45 search_path, schemas and functions...
Previous Message Miroslav Šulc 2005-03-16 21:51:09 Re: psql file restore - problem with encoding (solved)