Re: two primairy key in one table ?

Поиск
Список
Период
Сортировка
От Herbert Liechti
Тема Re: two primairy key in one table ?
Дата
Msg-id 3D25B673.1080301@thinx.ch
обсуждение исходный текст
Ответ на two primairy key in one table ?  (Angela Luyf <a.c.luyf@amc.uva.nl>)
Список pgsql-general
On Thu, 4 Jul 2002, Angela Luyf wrote:

 > Hello,
 > I have a database model where a many to many relation is used, so i need
 > to create a table with two primary key. Don't know how to solve this in
 > postgress, can't find it in the tutorials, so can anybody help me with
 > this ?

I always create a separate primary key field in the
intermediate table and do a unique index on the
other two fields.

   p1.p1Id                p2.p2Id
      \                     /
       \                   /
        \                 /
         \    t3.t3Id    /
              t3.p1Id
              t3.p2Id

besides of the normal primary and foreign keys I create
an unique index:

    create unique index on t3 (p1Id, p2Id);

Regards Herbie
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti                                  http://www.thinx.ch
The content management company.         Visit http://www.contentx.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




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

Предыдущее
От: Al Arduengo
Дата:
Сообщение: Re: Date Data Type
Следующее
От: Fathi Ben Nasr
Дата:
Сообщение: Re: Performance of ODBC-Driver /w IIS5.0/ColdFusion