Re: Using complex PRIMARY KEY - Mailing list pgsql-general

From A. Kretschmer
Subject Re: Using complex PRIMARY KEY
Date
Msg-id 20091008053150.GA26647@a-kretschmer.de
Whole thread Raw
In response to Using complex PRIMARY KEY  (Zsolt <zshorvat@freemail.hu>)
Responses Re: Using complex PRIMARY KEY
List pgsql-general
In response to Zsolt :
>
> This is our first project using PostgerSQL, where I have a problem I cant solve
> on a neat way (I assume PGSQL should provide a nice solution...).
>
> So we have an old xBase based program we are trying to port to PostgreSQL while
> we should keep the original data structure especially the ID fields must be
> kept as this IDs are already used in other systems.
>
> The problem is with two table, one is storing the data of houses the other the
> data of tenants in a given houses.
>
>
>
> For a given house I would like to start the numbering of tenants from 1. Each
> house could have tenant_ID=1, obviously in this case the house_ID will differ.
> The combination of tenant_ID and house_ID will be the unique identifier of each
> tenant.

Do you have PostgreSQL 8.4?

If yes, you can use CTE-functions for that. row_number().

Unfortunately, at the moment i haven't access to my database to create
an example, maybe later.


Regards, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)

pgsql-general by date:

Previous
From: paresh masani
Date:
Subject: Re: Need help in spi_prepare errors
Next
From: Gurjeet Singh
Date:
Subject: Re: Using complex PRIMARY KEY