Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 1, 2016 at 4:28 AM, Michelle Konzack
<linux4michelle@xxxxxxxxx> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux