Re: Help With complex join

From: Richard Huxton <dev(at)archonet(dot)com>
To: spinto(at)virtualslo(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Help With complex join
Date: 2005-07-15 08:57:36
Message-ID: 42D77A80.6060101@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

spinto(at)virtualslo(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kenneth Gonsalves 2005-07-15 09:46:02 Re: difference between all RDBMSs
Previous Message Richard Huxton 2005-07-15 08:52:06 Re: How to obtain the list of data table name only