Re: Help With complex join - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Help With complex join
Date
Msg-id 42D77A80.6060101@archonet.com
Whole thread Raw
In response to Help With complex join  (spinto@virtualslo.com)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: difference between all RDBMSs
Next
From: Richard Huxton
Date:
Subject: Re: How to obtain the list of data table name only