pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rajesh Kumar Mallah. <mallah@trade-india.com>
To: pgsql-sql@postgresql.org
Subject: Implementing automatic updating of primary keys...
Date: Thu, 16 Jan 2003 17:41:49 +0530
Message-ID: <200301161741.49024.mallah@trade-india.com> (raw)


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.





view thread (4+ messages)  latest in thread

Message-ID: <200301161741.49024.mallah@trade-india.com>
Permalink:  ../200301161741.49024.mallah@trade-india.com/
Also on:    postgresql.org/message-id/200301161741.49024.mallah@trade-india.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mallah@trade-india.com
  Subject: Re: Implementing automatic updating of primary keys...
  In-Reply-To: <200301161741.49024.mallah@trade-india.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox