Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: vehicle to autoparts relationships

Re: vehicle to autoparts relationships

From: Neo <neo55592_at_hotmail.com>
Date: 22 Nov 2006 12:59:38 -0800
Message-ID: <1164229178.442324.75740@b28g2000cwb.googlegroups.com>


> I have a challenge, to figure out what part of the vehicle to relate parts to ...

You will need a schema where parts can have parts recursively.

Below is a dbd example that models parts that make up a Civic LE and Civic SE. Each car has a different engine configuration and transmission however some parts like starter and gears are shared. Queries return each car's parts by traversing hierarchy. Queries return sum of each car's parts.

If you would like to see more specific data modelled in dbd, please post (or email).

Hierarchy of Parts Modelled:
CivicLE
  EngineCfg1
    1.5L Engine

       Starter1
    Gear2
  Manual Transmission
    Gear1

CivicSE
  EngineCfg2
    1.6L Engine

       Starter1
    Gear2
  Automatic Transmission
    Gear1

(new 'cost)

(new 'starter1 'starter)
(create starter1 cost (val+ '100))

(new 'eng_1.5L 'engine)
(create eng_1.5L part starter1)
(create eng_1.5L cost (val+ '1000))

(new 'eng_1.6L 'engine)
(create eng_1.6L part starter1)
(create eng_1.6L cost (val+ '1300))

(new 'gear1 'gear)
(create gear1 cost (val+ '5))

(new 'gear2 'gear)
(create gear2 cost (val+ '6))

(new 'trans_manual 'transmission)
(create trans_manual part gear1)
(create trans_manual cost (val+ '500))

(new 'trans_auto 'transmission)
(create trans_auto part gear1)
(create trans_auto cost (val+ '700))

(new 'engCfg1 'engineConfig)
(create engCfg1 part eng_1.5L)
(create engCfg1 part gear2)

(new 'engCfg2 'engineConfig)
(create engCfg2 part eng_1.6L)
(create engCfg2 part gear2)

(new 'honda 'mfg)

(new 'civic_le 'civic 'car)
(create civic_le mfg honda)
(create civic_le part engCfg1)
(create civic_le part trans_manual)

(new 'civic_se 'civic 'car)
(create civic_se mfg honda)
(create civic_se part engCfg2)
(create civic_se part trans_auto)

(; Find parts of civic_le)
(; Returns, engCfg1, eng_1.5L, starter1, gear2, trans_manual, gear1)
(selectRel civic_le part *)

(; Find parts of civic_se)
(; Returns, engCfg2, eng_1.6L, starter1, gear2, trans_auto, gear1)
(selectRel civic_se part *)

(; Get sum of civic_le part costs)
(; Return 1611)
(sum (select (nodeElem (selectRel civic_le part *)) cost *))

(; Get sum of civic_se part costs)
(; Returns 2111)
(sum (select (nodeElem (selectRel civic_se part *)) cost *))

For additional examples where things are made of things, see: www.dbfordummies.com/example/Ex117.asp
www.dbfordummies.com/example/Ex123.asp Received on Wed Nov 22 2006 - 14:59:38 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US