foreign key to "some rows" of a second table - Mailing list pgsql-general

From Chris Withers
Subject foreign key to "some rows" of a second table
Date
Msg-id 56CAEB1C.8030102@simplistix.co.uk
Whole thread Raw
Responses Re: foreign key to "some rows" of a second table
List pgsql-general
Hi All,

    So, I have a table that looks like this:


    CREATE TABLE config (
        region    varchar(10),
        name    varchar(10),
        value    varchar(40)
    );

    Another looks like this:

    CREATE TABLE tag (
        host    varchar(10),
        type    varchar(10),
        value    varchar(10)
    );

    What's the best way to set up a constraint on the 'config' table
    such that the 'region' column can only contain values that exist in
    the 'tag' table's value column where the 'type' is 'region'?

    cheers,

    Chris

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Why is my database so big?
Next
From: Achilleas Mantzios
Date:
Subject: Re: foreign key to "some rows" of a second table