foreign key to "some rows" of a second table

Поиск
Список
Период
Сортировка
От Chris Withers
Тема foreign key to "some rows" of a second table
Дата
Msg-id 56CAEB1C.8030102@simplistix.co.uk
обсуждение исходный текст
Ответы Re: foreign key to "some rows" of a second table  (Achilleas Mantzios <achill@matrix.gatewaynet.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Why is my database so big?
Следующее
От: Achilleas Mantzios
Дата:
Сообщение: Re: foreign key to "some rows" of a second table