Home » Developer & Programmer » Designer » double foreign key to the same table
double foreign key to the same table [message #90516] Wed, 07 January 2004 03:35 Go to next message
CK
Messages: 20
Registered: February 2001
Junior Member
Hi! I've got a design problem to see whether someone can help.

I've got a table storing the source and destination airport of a flight.

columns
-------
FLIGHT_ID VARCHAR2(10)
SRC_AIRPORT_ID VARCHAR2(10)
DES_AIRPORT_ID VARCHAR2(10)

In order not to duplicate the info, I define a static table to store airport-specifi attributes like (landing fee, number of lanes, etc.)

columns
------
AIRPORT_ID VARCHAR2(10)
LANDING_FEE NUMBER(5,2)
NO_OF_LANES NUMBER(2,0)

The flight table has two foreign keys (SRC_AIRPORT_ID, DES_AIRPORT_ID) pointing to the airport attribute table (AIRPORT_ID). How can this be represented in the ER diagram?

Thanks.
Re: double foreign key to the same table [message #90522 is a reply to message #90516] Sun, 18 January 2004 08:06 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
It's perfectly valid to have two (or more) foreign keys between two tables (relationships between two entities) like this. Just put them both on the diagram.
Re: double foreign key to the same table [message #90531 is a reply to message #90516] Tue, 27 January 2004 10:30 Go to previous message
Martyn Roberts
Messages: 9
Registered: July 2003
Junior Member
Hi CK,

Schemester, the free ER modelling tool for Oracle at http://www.schemester.com, will draw this kind of relationship for you.
Previous Topic: forms in designer2000
Next Topic: Best Practices for Architecting Databases?
Goto Forum:
  


Current Time: Sun Nov 24 04:02:47 CST 2024