Re: [GENERAL] Multiple table relationship constraints

2011-05-09 Thread Jack Christensen
On 5/5/2011 3:26 PM, Rick Genter wrote: Hm. I think the way I would handle this is to put the business logic for inserting/updating into the room_assignments table into one or more functions and have a special user that owns the tables and owns the functions and declare the functions to be SE

Re: [GENERAL] Multiple table relationship constraints

2011-05-06 Thread Misa Simic
I think the best way is what David has suggested... But if it is already live, and there is no way to handle clients app to work with functions (instead of Direct SQL statements) then I think trigger function would help... (not sure how it could be error prone..) So basically if function is Val

Re: [GENERAL] Multiple table relationship constraints

2011-05-05 Thread Rick Genter
On Thu, May 5, 2011 at 4:14 PM, Jack Christensen wrote: > It's not denormalized. It is an attribute that both tables have that have > to match for it to be a valid link. > > Here's a contrived example: > > CREATE TABLE dorms( > dorm_id serial PRIMARY KEY, > gender varchar NOT NULL, > ... > )

Re: [GENERAL] Multiple table relationship constraints

2011-05-05 Thread Jack Christensen
On 5/5/2011 2:53 PM, Rick Genter wrote: On Thu, May 5, 2011 at 3:50 PM, Jack Christensen mailto:ja...@hylesanderson.edu>> wrote: The trick is there are additional attributes of actions and achievements such as a category that must match for the link to be valid. These attributes are

Re: [GENERAL] Multiple table relationship constraints

2011-05-05 Thread Rick Genter
On Thu, May 5, 2011 at 3:50 PM, Jack Christensen wrote: > The trick is there are additional attributes of actions and achievements > such as a category that must match for the link to be valid. These > attributes are not part of the primary key of either record and can and do > change. > So your

Re: [GENERAL] Multiple table relationship constraints

2011-05-05 Thread Jack Christensen
On 5/5/2011 2:28 PM, Rick Genter wrote: On Thu, May 5, 2011 at 3:20 PM, Jack Christensen mailto:ja...@hylesanderson.edu>> wrote: What is the best way to handle multiple table relationships where attributes of the tables at the ends of the chain must match? Example: CREATE TABL

Re: [GENERAL] Multiple table relationship constraints

2011-05-05 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Jack Christensen > Sent: Thursday, May 05, 2011 3:20 PM > To: pgsql > Subject: [GENERAL] Multiple table relationship constraints > > 4. Validate application side -- t

Re: [GENERAL] Multiple table relationship constraints

2011-05-05 Thread Rick Genter
On Thu, May 5, 2011 at 3:20 PM, Jack Christensen wrote: > What is the best way to handle multiple table relationships where > attributes of the tables at the ends of the chain must match? > > Example: > > CREATE TABLE achievements( > achievement_id serial PRIMARY KEY, > ... > ); > > CREATE TABLE a