Re: Duplicate information in parent and child tables - Mailing list pgsql-novice

From Chetan Suttraway
Subject Re: Duplicate information in parent and child tables
Date
Msg-id CAPtHcnFVbyRR_qi2rhcMbe8rAfD1sK5Y=RcSB88JuR7sxzAt8g@mail.gmail.com
Whole thread Raw
In response to Duplicate information in parent and child tables  (JORGE MALDONADO <jorgemal1960@gmail.com>)
List pgsql-novice


On Tue, Jan 10, 2012 at 1:42 AM, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:
I have a parent table and a child table. In order to detect duplicate information I need to consider both tables. This means that a "duplicate record" consists of one parent record and one or more child records. 
Is there any standard approach to solve this issue?



You can create additional table that stores all record from parent as well child.
For example, whenever a record is inserted in parent table, the same/copy of record should
be inserted into this table. Then all you need is to put up constraints for handling uniqueness.
Note that you would also need to handle updates,deletes so that we are not left with any dangling records in additional table.

Note that there are others ways to handle the uniqueness in inheritance setup.
you might want to take a look at all before coming up with the final strategy.

Regards,
Chetan

--
EnterpriseDB Corporation
The Enterprise PostgreSQL Company

EnterpriseDB Blog : http://blogs.enterprisedb.com




pgsql-novice by date:

Previous
From: JORGE MALDONADO
Date:
Subject: HTML encode/decode
Next
From: Chetan Suttraway
Date:
Subject: Re: Partitioning: avoid insert in master table