X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id E8B239FA3AD for ; Wed, 7 Jun 2006 16:04:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 62204-04 for ; Wed, 7 Jun 2006 16:04:26 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web33305.mail.mud.yahoo.com (web33305.mail.mud.yahoo.com [68.142.206.120]) by postgresql.org (Postfix) with SMTP id 563889FA2E6 for ; Wed, 7 Jun 2006 16:04:25 -0300 (ADT) Received: (qmail 67117 invoked by uid 60001); 7 Jun 2006 19:04:23 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=3ey57ER8Tutta+fEfQQlxmuU8NCjcusDcooPbFEBI6dGQSGtn8DYg+bKaCWBvM6xPPJn8OmDdKJTeFMyysgVVpwC/Qts0xDCFNwDWbOh90KmccKo8YcvphbzKS2KxPVtgQs7t+v/lOIdvpsj8+2Dg2DfADKv6jB6PeGfIE0tYNE= ; Message-ID: <20060607190423.67115.qmail@web33305.mail.mud.yahoo.com> Received: from [12.9.179.126] by web33305.mail.mud.yahoo.com via HTTP; Wed, 07 Jun 2006 12:04:23 PDT Date: Wed, 7 Jun 2006 12:04:23 -0700 (PDT) From: Subject: Re: Join issue To: Burak Seydioglu , Michael Glaesemann Cc: ken@scottshill.com, operationsengineer1@yahoo.com, pgsql-sql@postgresql.org In-Reply-To: <1b8a973c0606071051l2fee7febj84c7c310b90ff272@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/85 X-Sequence-Number: 25321 > Table structures: > > ce_house > ==================== > house_id > provider_id > > ce_contract > ==================== > contract_id > house_id > contract_term > contract_created > > ce_contract_status > ==================== > contract_status_id > contract_id > contract_status > contract_status_created > > ce_provider > ==================== > provider_id > provider_name > > ce_provider_rate > ==================== > provider_rate_id > provider_id > provider_rate_amount > provider_rate_created if i'm reading this right, a house can only have one provider, but a house can have multiple contracts. at first glance, i'd think the contracts should be associated with the provider, not the house. if true, you need to update your table structure. is the rate associated with the contract (i'd assume so with limited informationthink so) or the provider (the way you have it set up)? this is how i envision the table structure (granted, i have limited information so i coul dbe way off base)... ce_house ==================== house_id ce_provider ==================== provider_id ** house_id (fkey) ** provider_name ce_contract ==================== contract_id ** provider_id (fkey) ** contract_term contract_created ce_contract_status ==================== contract_status_id contract_id (fkey) contract_status contract_status_created ** ce_contract_rate ** ==================== contract_rate_id contract_id (fkey) contract_rate_amount contract_rate_created i also assume, based on your structure, that you can have multiple contract statuses for a given contract. if not,you could probably delete that table and just add contract_status and contract_status_created to ce_contract. i'm sorry if i'm way off base, but i'm trying to wrap my head around the table strcuture, but i'm not necessarily familiar with all the business rules that created the structure - so i may be way off base here. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com