Multiple keys?

Поиск
Список
Период
Сортировка
От Casey Allen Shobe
Тема Multiple keys?
Дата
Msg-id 200208280210.44746.cshobe@secureworks.net
обсуждение исходный текст
Ответы Re: Multiple keys?  (Richard Poole <rp@guests.deus.net>)
Список pgsql-admin
In order to get the foreign key I want working, I had to have two unique
references on the parent table, though the second covers two columns that are
contained within the first.  Is this wise?  Is there a better way?

create table    "package_info" (
    "info_id" integer        not null unique default
        nextval('package_info_info_id_seq') primary key,
    "package_id"    integer        not null references "packages" ("package_id"),
    "package_version" varchar(16)    not null default '0.0.1',
    "info_type"    varchar(32)    not null default 'extra_data',
    "info_value"    text        not null default 'Default',
    unique ("package_id", "package_version", "info_type"),
    unique ("package_id", "package_version")
);

create table    "box_packages" (
    "install_id"    integer        not null unique default
        nextval('box_packages_install_id_seq') primary key,
    "box_id"    integer        not null references "boxes" ("box_id"),
    "package_id"    integer        not null,
    "package_version" varchar(16)    not null,
    "install_date"    timestamp with time zone not null,
    "uninstall_data" timestamp with time zone,
    foreign key ("package_id", "package_version") references
        "package_info" ("package_id", "package_version"),
    unique ("box_id", "package_id", "package_version", "install_date")
);

Danke,

--
Casey Allen Shobe / Network Security Analyst & PHP Developer
SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144
cshobe@secureworks.net / http://www.secureworks.net
Content is my own and does not necessarily represent my company.

В списке pgsql-admin по дате отправления:

Предыдущее
От: Tim Ellis
Дата:
Сообщение: Re: thanks for tedia2sql
Следующее
От: Andre Schubert
Дата:
Сообщение: Errors with pg_dump