X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 509C19FB309 for ; Mon, 31 Jul 2006 21:12:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 17349-08 for ; Tue, 1 Aug 2006 00:12:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtpgate1.pacific.net.sg (smtpgate1.pacific.net.sg [203.120.90.31]) by postgresql.org (Postfix) with SMTP id B6F189FA48B for ; Mon, 31 Jul 2006 21:12:27 -0300 (ADT) Received: (qmail 6205 invoked from network); 1 Aug 2006 00:12:24 -0000 Received: from ppp228.dyn77.pacific.net.sg (HELO ?127.0.0.1?) (debraneys@210.24.77.228) by smtpgate1.pacific.net.sg with (DHE-RSA-AES256-SHA encrypted) ESMTPA; 1 Aug 2006 00:12:23 -0000 Message-ID: <44CE9C63.7010409@debraneys.com> Date: Tue, 01 Aug 2006 08:12:19 +0800 From: John Tregea User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Aaron Bono CC: pgsql-sql@postgresql.org Subject: Re: Joining a result set from four (4) tables References: <44CDB1EF.6000508@debraneys.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.816 tagged_above=0 required=5 tests=SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200607/384 X-Sequence-Number: 25958 Hi aaron, Here are the 'create table' statements. I have indicated what are the primary and foreign keys with trailing comments. Thanks John Aaron Bono wrote: > Can you include the table create statements with primary and foreign > keys? That would help a lot. CREATE TABLE resources ( serial_id numeric NOT NULL, -- << Primary Key related_id numeric, -- << Foreign Key host_id int4, created timestamptz DEFAULT now(), modified timestamptz, valid_from timestamp, valid_to timestamp, schema_name varchar(32), grid_loc varchar(32), name varchar(32), status varchar(16), description text, comments text, sort_order int2, user_id int4 DEFAULT 0, located text, classification varchar(32), sequence_id int4, ) CREATE TABLE actions ( serial_id numeric NOT NULL, -- primary key related_id numeric, -- foreign key on resources.serial_id host_id int4, created timestamptz DEFAULT now(), modified timestamptz, valid_from timestamp, valid_to timestamp, name varchar(32), status varchar(16) DEFAULT 'Active'::character varying, description text, comments text, sort_order int2 DEFAULT 0, user_id int4 DEFAULT 0, -- User_ID of the creator located text, classification varchar(32), sequence_id int4, in_box varchar(32), display_group varchar(2), ) CREATE TABLE policies ( serial_id numeric NOT NULL, -- primary key related_id numeric, -- foreign key on actions.serial_id resource_id numeric, -- foreign key on resources.serial_id owner_id numeric, authority_id int4, created timestamptz DEFAULT now(), modified timestamptz, valid_from timestamp, valid_to timestamp, status varchar(16) DEFAULT 'Active'::character varying, description text, comments text, classification varchar(32), user_id int4, sequence_id int4, inheritance text, ) CREATE TABLE permissions ( serial_id numeric NOT NULL, -- primary key related_id numeric, -- foreign key on policies.serial_id user_id int4, -- foreign key on users.serial_id owner_id int4, authority_id int4, resource_id int4, created timestamptz DEFAULT now(), modified timestamptz, valid_from timestamp, valid_to timestamp, name varchar(32), acronym varchar(6), status varchar(16) DEFAULT 'Active'::character varying, inheritance text, description text, comments text, sort_order int2, user_id int4 DEFAULT 0, located text, classification varchar(32), sequence_id int4, ) CREATE TABLE users ( serial_id numeric NOT NULL, -- primary key created timestamptz DEFAULT now(), modified timestamptz, valid_from timestamp, valid_to timestamp, name varchar(64) NOT NULL, acronym varchar(6), status varchar(16), inheritance text, description text NOT NULL, comments text NOT NULL, sort_order int2 NOT NULL, clearance varchar(32) NOT NULL, administrator bool DEFAULT false, user_id int4 DEFAULT 0, next_serial_id int4 DEFAULT 1, classification varchar(32), )