Re: foreign key constraints with inhertiance, hack suggestions?

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: George Nychis <gnychis(at)cmu(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: foreign key constraints with inhertiance, hack suggestions?
Date: 2007-03-22 09:00:23
Message-ID: 460245A7.5030800@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

George Nychis wrote:
> Basically I have a master 'flows' table which is partitioned and has
> non-overlapping CHECK constraints on each partition. Each record in the
> partitions have a unique pair of attributes: interval, flow_id
>
> When inserting in to another table 'flow_labels', these two attributes
> are given, I want to ensure that there exists a single flow in some
> partition in the 'flows' table that has these two values.
>
> I'm no DB expert, but could there be some sort of rule or trigger on
> insert into 'flow_labels' that does a count() where these two values are
> exact to ensure there exists 1 flow? Problem is my 'flows' table is on
> the order of billions of flows, each partition having hundreds of
> thousands.

I think count() would be a last resort solution. If possible, I think it
would help to add the interval data to your 'flow_labels' table and join
on the combined key. That way the information that divides your 'flows'
into different tables is available at join time, and constraint
exclusion could do its work.

That'd still require some way to inherit constraints, but it's a start.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2007-03-22 09:04:41 Re: questions about query design
Previous Message Stephen Liu 2007-03-22 07:56:08 Problem on installing postgresql-devel