Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4B1BE476333 for ; Thu, 16 Jan 2003 07:06:43 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 7FE68476173 for ; Thu, 16 Jan 2003 07:06:39 -0500 (EST) Received: (qmail 1629 invoked from network); 16 Jan 2003 12:01:27 -0000 Received: from unknown (HELO system67.trade-india-local.com) (192.168.0.67) by infocom-236-129-del.trade-india.com with SMTP; 16 Jan 2003 12:01:27 -0000 From: "Rajesh Kumar Mallah." Organization: Infocom Network Limited. To: pgsql-sql@postgresql.org Subject: Implementing automatic updating of primary keys... Date: Thu, 16 Jan 2003 17:41:49 +0530 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200301161741.49024.mallah@trade-india.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/259 X-Sequence-Number: 11124 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.