Implementing automatic updating of primary keys...

From: "Rajesh Kumar Mallah(dot)" <mallah(at)trade-india(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Implementing automatic updating of primary keys...
Date: 2003-01-16 12:11:49
Message-ID: 200301161741.49024.mallah@trade-india.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi we are working on re-structuring our database schemas and
intend to implement the functionality below at database level.

consider a master table with following data.

Table: profile_master
------------

id | username | password
---|----------|----------
1 | u1 | p1
2 | u2 | p2

id--> primary key not null.

table t1
-----------

id | service_id
---|------------
1 | 1
2 | 10

table t2
--------------

id | rfi_id
---|-----------
1 | 1001
2 | 23

there can be many such tables that have foreign key id which is referencing
the master table test_master column "id". what we want is when some ids become
redundant we have to merge two ids , we want that thru out the system the
occurance of the old primary key shud be removed and replaced with the new id.

so if id 2 were to be mergered to id 1 then the tables shud look like:

Table: profile_master
------------

id | username | password
---|----------|----------
1 | u1 | p1

id--> primary key not null.

table t1
-----------

id | service_id
---|------------
1 | 1
1 | 10

table t2
--------------

id | rfi_id
---|-----------
1 | 1001
1 | 23

can some thing be done in the database level it self so that we do not have
to keep modifying the mantainence programs as the number of tables referencing
master table grows?

regds
mallah.

--
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)

Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rajesh Kumar Mallah. 2003-01-16 14:28:17 Re: Implementing automatic updating of primary keys...
Previous Message Marko Asplund 2003-01-16 11:32:36 Re: Oracle outer join porting question