RE: Unique or Primary Key?

Поиск
Список
Период
Сортировка
От Joel Burton
Тема RE: Unique or Primary Key?
Дата
Msg-id Pine.LNX.4.21.0105031648200.8245-100000@olympus.scw.org
обсуждение исходный текст
Ответ на RE: Unique or Primary Key?  ("Christian Marschalek" <cm@chello.at>)
Список pgsql-general
> > Besides, I couldn't see much use in creating it as a primary
> > key.  How
> > would I ever reference it from another table?

If you're questioning how to use a multi-field primary key, it's easy...


create table p (id1 int not null, id2 int not null, primary key(id1,
id2));

create table c (id1 int, id2 int, foreign key (id1, id2) references p);

insert into p values (1,2);
insert into c values (1,1);
insert into c values (1,0);

ERROR:  <unnamed> referential integrity violation - key referenced from c
not found in p

--
Joel Burton   <jburton@scw.org>
Director of Information Systems, Support Center of Washington


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

Предыдущее
От: Joel Burton
Дата:
Сообщение: Metaphone function attachment
Следующее
От: "Mitch Vincent"
Дата:
Сообщение: Re: Ideal hardware - OS Wars are silly.