Re: Composite Keys

Поиск
Список
Период
Сортировка
От Jorge Godoy
Тема Re: Composite Keys
Дата
Msg-id 200702241522.56438.jgodoy@gmail.com
обсуждение исходный текст
Ответ на Composite Keys  (RPK <rohitprakash123@indiatimes.com>)
Ответы Re: Composite Keys  (RPK <rohitprakash123@indiatimes.com>)
Список pgsql-general
Em Sábado 24 Fevereiro 2007 03:28, RPK escreveu:
> First, can a primary key field be only one? I mean can I define a primary
> containing two fields.
>
> I have a table called "Payments" where there are two fields, "ReceiptNo"
> and "PaymentDate". If I take "ReceiptNo" only as a primary key then chances
> are of "primary key violation". Because in some places the receipt books
> have numbers that start with 1. I mean Receipt Book 1 nos. 1-100. Receipt
> Book 2 nos. 1-100, and so on.
>
> So I want to take ReceiptNo and PaymentDate as primary key field. Is it
> possible to define composite key in PGSQL. Please also suggest if any other
> approach would be fine.

It is possible, but it looks like you'd really want ReceiptBookNo + ReceiptNo
as a primary key...

If you use that you can then control the number of left recipes on each
receipt book or when to order new books.

If you use the date take special care with long term payments so that you
don't have two recipes "10" scheduled for the same day.

--
Jorge Godoy      <jgodoy@gmail.com>


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

Предыдущее
От: Ron Johnson
Дата:
Сообщение: Re: perfromance world records
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: perfromance world records