Re: COL unique (CustomerID) plus COL unique (COUNT) inside CustomerID

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: COL unique (CustomerID) plus COL unique (COUNT) inside CustomerID
Дата
Msg-id CACjxUsOgn9nvfiCbm3BtyVTV4rEYbUkpU9pbw0o2=teXhGvt+w@mail.gmail.com
обсуждение исходный текст
Ответ на COL unique (CustomerID) plus COL unique (COUNT) inside CustomerID  (Michelle Konzack <linux4michelle@gmail.com>)
Список pgsql-general
On Thu, Sep 1, 2016 at 4:28 AM, Michelle Konzack
<linux4michelle@gmail.com> wrote:

> I need a table with an UNIQUE CustomerID which is working fine...
>
> ...BUT I need also a second column with a count, which  must  be  UNIQUE
> inside the CustomerID.

Just to be clear, you probably have a customer table with "CustIomerId"
as its key and are talking about a "child"of that where you want a
2-column key?

> In clear this:
>
>     CustID       Count
>          1           1
>          1           2
>          1           3
>
>          2           1
>          2           2
>
>          3           1
>          3           2
>          3           3
>          ...
>
> How to do this?

If, for example, the child table is a list of customer contacts,
you might add a "LastContactNo" column to the customer table,
defaulting to zero on customer insert, and which you increment to
get values for the second key column in the contact table.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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

Предыдущее
От: "Mike Sofen"
Дата:
Сообщение: Re: Rackspace to RDS using DMS (Postgres 9.2)
Следующее
От: Eduardo Morras
Дата:
Сообщение: Re: Clustered index to preserve data locality in a multitenant application?