db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Moore <bradm6...@hotmail.com>
Subject RE: Determine which child table a record belongs to
Date Tue, 29 Jan 2008 17:54:16 GMT
Can I suggest changing the "Crane" table to include a CraneType column or something similar?
 I don't know if there is a reason that's not obvious to me why you need all of the other
tables.  It looks like you're using the other tables to determine the type of crane, the same
thing could be done with one additional column in the Crane table.  That would simplify your
database design a lot.  Unless I'm missing something.

Brad

> Date: Tue, 29 Jan 2008 09:46:09 -0800
> From: mz_tricsta@yahoo.com
> To: derby-user@db.apache.org
> Subject: Determine which child table a record belongs to
> 
> 
> Hello All,
> 
> I have the following tables in my database -:
> 
> CREATE TABLE Crane
> (
> PTTEquipmentID INTEGER NOT NULL,
> LiftingCapacity INTEGER NOT NULL,
> PRIMARY KEY (PTTEquipmentID),
> FOREIGN KEY (PTTEquipmentID) REFERENCES Equipment ON DELETE CASCADE
> )
> 
> CREATE TABLE RoughTerrainCrane
> (
> PTTEquipmentID INTEGER NOT NULL,
> PRIMARY KEY (PTTEquipmentID),
> FOREIGN KEY (PTTEquipmentID) REFERENCES Crane ON DELETE CASCADE
> )
> 
> CREATE TABLE AllTerrainCrane
> (
> PTTEquipmentID INTEGER NOT NULL,
> PRIMARY KEY (PTTEquipmentID),
> FOREIGN KEY (PTTEquipmentID) REFERENCES Crane ON DELETE CASCADE
> )
> 
> CREATE TABLE TruckCrane
> (
> PTTEquipmentID INTEGER NOT NULL,
> PRIMARY KEY (PTTEquipmentID),
> FOREIGN KEY (PTTEquipmentID) REFERENCES Crane ON DELETE CASCADE
> )
> 
> CREATE TABLE CarryDeckCrane
> (
> PTTEquipmentID INTEGER NOT NULL,
> PRIMARY KEY (PTTEquipmentID),
> FOREIGN KEY (PTTEquipmentID) REFERENCES Crane ON DELETE CASCADE
> )
> 
> CREATE TABLE CrawlerCrane
> (
> PTTEquipmentID INTEGER NOT NULL,
> PRIMARY KEY (PTTEquipmentID),
> FOREIGN KEY (PTTEquipmentID) REFERENCES Crane ON DELETE CASCADE
> )
> 
> CREATE TABLE RingCrane
> (
> PTTEquipmentID INTEGER NOT NULL,
> PRIMARY KEY (PTTEquipmentID),
> FOREIGN KEY (PTTEquipmentID) REFERENCES Crane ON DELETE CASCADE
> )
> 
> 'Crane' is the parent table of 'RoughTerrainCrane', 'AllTerrainCrane',
> 'TruckCrane', 'CarryDeckCrane', 'CrawlerCrane' and 'RingCrane'. If I have a
> 'Crane' key, how do I determine which of the child tables the key belongs to
> without querying each child table?
> 
> I greatly appreciate any effort to help me. Thank you for your time and
> consideration.
> 
> Sincerely,
> Tricsta
> -- 
> View this message in context: http://www.nabble.com/Determine-which-child-table-a-record-belongs-to-tp15164998p15164998.html
> Sent from the Apache Derby Users mailing list archive at Nabble.com.
> 

_________________________________________________________________


Mime
View raw message