pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Magne Mæhre <Magne.Mahre@Sun.COM>
To: Colin Wetherbee <cww@denterprises.org>
Cc: Phillip Smith <phillip.smith@weatherbeeta.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: JOIN a table twice for different values in the same query
Date: Tue, 15 Jan 2008 14:20:45 +0100
Message-ID: <478CB32D.6050304@sun.com> (raw)
In-Reply-To: <47869EF7.70106@denterprises.org>
References: <002f01c853d7$63bc0680$9b0014ac@wbaus090>
	<47869C8C.4080109@denterprises.org>
	<47869EF7.70106@denterprises.org>

Colin Wetherbee wrote:
> Colin Wetherbee wrote:
>> Phillip Smith wrote:
>>> As a side note - all the IATA codes are unique for each airport -
>>> wouldn't it be better to use these as the Primary Key and Foreign
>>> Keys? Then you wouldn't have to even join the tables unless you
>>> wanted the port names (not just the code)
>>
>> This is true, but FWIW, my application will mostly be joining for the 
>> name of the airport or the city, not the code.
>>
>> I'll keep the idea of using the codes as keys in mind, though.  Thanks 
>> for pointing that out.
> 
> Oh, now I remember why I'm using IDs as keys. ;)
> 
> The code isn't always going to be an airport, and, for example, a train 
> station in Buenos Aires could conceivably have the same code as a 
> shipping port in Rotterdam, which, in turn, might well be JFK. :)

Note that IATA codes are _NOT_ unique.   The current list of IATA 
trigrams list upward of 300 duplicate codes.  If you include the train 
stations, there might be additional collisions.

You could consider using the ICAO four-letter identifiers instead. They 
are unique, and are preferred by airspace management authorities.  A 
mapping to the corresponding IATA code exists.

--Magne



view thread (9+ messages)  latest in thread

Message-ID: <478CB32D.6050304@sun.com>
Permalink:  ../478CB32D.6050304@sun.com/
Also on:    postgresql.org/message-id/478CB32D.6050304@sun.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: Magne.Mahre@Sun.COM, cww@denterprises.org, phillip.smith@weatherbeeta.com.au
  Subject: Re: JOIN a table twice for different values in the same query
  In-Reply-To: <478CB32D.6050304@sun.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