pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedPartitioned Tables Foreign Key Constraints Problem
2+ messages / 2 participants
[nested] [flat]
* Partitioned Tables Foreign Key Constraints Problem
@ 2008-07-24 10:15 Gauri Kanekar <meetgaurikanekar@gmail.com>
2008-07-25 22:31 ` Re: Partitioned Tables Foreign Key Constraints Problem Josh Berkus <josh@agliodbs.com>
0 siblings, 1 reply; 2+ messages in thread
From: Gauri Kanekar @ 2008-07-24 10:15 UTC (permalink / raw)
To: pgsql-performance
Hi all,
Have a problem related to partition tables.
We have the following schema's :
master -
id integer (PRIMARY KEY)
cid integer
child1, child2 are the child tables of master table. Here "cid" is the field
used for partitioning.
We have another table called
other_tbl -
id integer (PRIMARY KEY)
m_id integer (FOREIGN KEY FROM master(id))
Now the problem is, since other_tbl->m_id referenced from master->id, if we
try to insert any vales in "other_tbl" for m_id its checks it presence in
only master table and not in its child table. As the master table is always
empty in partitions tables a foreign key violation ERROR is being given.
How can we define the Foreign_key constraint on "other_tbl" based upon any
partitioned table field.
--
Regards
Gauri
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Partitioned Tables Foreign Key Constraints Problem
2008-07-24 10:15 Partitioned Tables Foreign Key Constraints Problem Gauri Kanekar <meetgaurikanekar@gmail.com>
@ 2008-07-25 22:31 ` Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 2+ messages in thread
From: Josh Berkus @ 2008-07-25 22:31 UTC (permalink / raw)
To: Gauri Kanekar <meetgaurikanekar@gmail.com>; +Cc: pgsql-performance
Gauri,
> How can we define the Foreign_key constraint on "other_tbl" based upon
> any partitioned table field.
Currently PostgreSQL doesn't have any simple way to support this. There
are a few workarounds, but they're fairly awkward, such as a trigger to
check if the ID is correct.
--Josh
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-07-25 22:31 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-07-24 10:15 Partitioned Tables Foreign Key Constraints Problem Gauri Kanekar <meetgaurikanekar@gmail.com>
2008-07-25 22:31 ` Josh Berkus <josh@agliodbs.com>
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