Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id A9D4E2E476B for ; Thu, 10 Jan 2008 18:41:26 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 18412-03 for ; Thu, 10 Jan 2008 18:41:09 -0400 (AST) Received: from smtpauth.rollernet.us (smtpauth.rollernet.us [208.11.75.5]) by postgresql.org (Postfix) with ESMTP id 898292E3ACA for ; Thu, 10 Jan 2008 18:41:23 -0400 (AST) Received: from smtpauth.rollernet.us (localhost.localdomain [127.0.0.1]) by smtpauth.rollernet.us (Postfix) with ESMTP id BB06D59400A; Thu, 10 Jan 2008 14:41:20 -0800 (PST) Received: from iron.denterprises.org (ool-4350518c.dyn.optonline.net [67.80.81.140]) by smtpauth.rollernet.us (Postfix) with ESMTP; Thu, 10 Jan 2008 14:41:20 -0800 (PST) Received: from [127.0.0.1] (kell.iron.denterprises.org [192.168.171.80]) by iron.denterprises.org (Postfix) with ESMTP id B117E167580; Thu, 10 Jan 2008 17:41:19 -0500 (EST) Message-ID: <47869EF7.70106@denterprises.org> Date: Thu, 10 Jan 2008 17:40:55 -0500 From: Colin Wetherbee User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Phillip Smith CC: pgsql-sql@postgresql.org Subject: Re: JOIN a table twice for different values in the same query References: <002f01c853d7$63bc0680$9b0014ac@wbaus090> <47869C8C.4080109@denterprises.org> In-Reply-To: <47869C8C.4080109@denterprises.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 080109-0, 01/09/2008), Outbound message X-Antivirus-Status: Clean X-Rollernet-Abuse: Processed by Roller Network Mail Services. Contact abuse@rollernet.us to report violations. Abuse policy: http://rollernet.us/abuse.php X-Rollernet-Submit: Submit ID 35fd.47869f10.a46f6.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/83 X-Sequence-Number: 29936 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. :) Colin