Обсуждение: Duplicate information in parent and child tables

Поиск
Список
Период
Сортировка

Duplicate information in parent and child tables

От
JORGE MALDONADO
Дата:
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?

Respectfully,
Jorge Maldonado

Re: Duplicate information in parent and child tables

От
Chetan Suttraway
Дата:


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