pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: spinto@virtualslo.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Help With complex join
Date: Fri, 15 Jul 2005 09:57:36 +0100
Message-ID: <42D77A80.6060101@archonet.com> (raw)
In-Reply-To: <1121376842.249209.127400@z14g2000cwz.googlegroups.com>
References: <1121376842.249209.127400@z14g2000cwz.googlegroups.com>

spinto@virtualslo.com wrote:
> Hi all, got a question as how to approach a somewhat complicated join
> query.  The deal is I have three tables called attorney, lawOffice, and
> law_office_employment.  The attorney and lawOffice tables hold attorney
> and lawOffice information respectively (obviously).  The
> law_office_employment table is meant to show historical periods of time
> for which the attorney's worked for the different lawOffices.

But it doesn't. Looking below, it shows the date they started in each 
law office, not the period they worked there.

In fact, you can't capture a period of unemployment/sabbatical using 
just this table.

 > Here is
> the create table statement for law_office_employment:
> 
> /*==============================================================*/
> /* Table: LAW_OFFICE_EMPLOYMENT                                 */
> /*==============================================================*/
> create table LAW_OFFICE_EMPLOYMENT (
> ATTORNEYID           IDENTIFIER           not null,
> LAWOFFICEID          IDENTIFIER           not null,
> STARTDATE            DATE                 not null,
> constraint PK_LAW_OFFICE_EMPLOYMENT primary key (ATTORNEYID,
> LAWOFFICEID, STARTDATE)
> );

Make your life easier and have start and end-dates. Oh, you might want a 
"finished-here" flag too to indicate the end-date can be checked.

--
   Richard Huxton
   Archonet Ltd



view thread (3+ messages)

Message-ID: <42D77A80.6060101@archonet.com>
Permalink:  ../42D77A80.6060101@archonet.com/
Also on:    postgresql.org/message-id/42D77A80.6060101@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, spinto@virtualslo.com
  Subject: Re: Help With complex join
  In-Reply-To: <42D77A80.6060101@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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