Re: Tree (forest) design

From: Neo <neo55592_at_hotmail.com>
Date: 2 Mar 2004 18:40:06 -0800
Message-ID: <4b45d3ad.0403021840.17b3a0cf_at_posting.google.com>


> This a real requirements set, for a real project, not a school exercise.

While you will not directly be able to use the solution presented below, it may provide some ideas. Actually the experimental db partially resulted from difficulties to represent/code, in a generic/flexible manner, applications just like yours (different kinds of things in variable hierarchies).

The solution is posted at www.xdb1.com/Example/Ex107.asp The solution represents companies (GM and Ford) and their inventory of parts (just 4) located through out the world (Detroit, Matamoros). Things may be arranged in the following hierarchy: country, region, state, city, site, building, floor, room, rack, bin, part. In some cases, levels can be missing.

Figure 1 shows classes and their instances. Figure 2 shows a hierarchal arrangement of those instances. Note, GM's operation shows all levels while Ford's operation has some levels missing.
Figure 3 shows a simple table of the 4 parts and their manufacturers.

To rearrange things in hierarchy, use cut and paste just as in Windows File Explorer. It is easy to insert new levels in different parts of the hierarchy. One method of entering the data is by typing the sentences below. The db automatically handles normalization, referential links, etc.

company isa thing.
gm isa company.
ford isa company.
maserk isa company.

owner isa thing.
* isa owner. (create an unnamed instance) it isa gm. (it refers to the unnamed instance)

  • isa owner. it isa ford.
  • isa owner. it isa maserk.

mfg isa thing.
* isa mfg.
it isa gm.

  • isa mfg. it isa ford.

country isa thing.
usa isa country.
mexico isa country.

region isa thing.
tampaulipus isa region.

state isa thing.
michigan isa state.

city isa thing.
detroit isa city.
matamoros isa city.

site isa thing.
gmFabSite1 isa site.

building isa thing.
bldgG1 isa building.
bldgG1's owner is gm.
bldgF1 isa building.
bldgF1's owner is ford.

floor isa thing.
floor1 isa floor.
floor2 isa floor.

room isa thing.
roomG1a isa room.
roomG1b isa room.

rack isa thing.
rackG1b1 isa rack.
rackG1b2 isa rack.

bin isa thing.
binG1b2a isa bin.
binG1b2a's owner is maserk.
binG1b2b isa bin.
binG1b2b's owner is maserk.

part isa thing.
partG1 isa part.
partG1's mfg is gm.
partG2 isa part.
partG2's mfg is gm.
partF1 isa part.
partF1's mfg is ford.
partF2 isa part.
partF2's mfg is ford.

isIn isa relator. (create relator for hierarchy)

earth isa thing.
earth equals earth. (create root of hierarchy) it is isIn. (relate isIn with hierarchy)

usa isIn earth.
mexico isIn earth.

michigan isIn usa.
detroit isIn michigan.
gmFabSite1 isIn detroit.
bldgG1 isIn gmFabSite1.
floor1 isIn bldgG1.
floor2 isIn bldgG1.
roomG1a isIn floor2.
roomG1b isIn floor2.
rackG1b1 isIn roomG1b.
rackG1b2 isIn roomG1b.
binG1b2a isIn rackG1b2.
binG1b2b isIn rackG1b2.
partG1 isIn binG1b2b.
partG2 isIn binG1b2b.

tampaulipus isIn mexico.
matamoros isIn tampaulipus.
bldgF1 isIn matamoros.
partF1 isIn bldgF1.
partF2 isIn bldgF1. Received on Wed Mar 03 2004 - 03:40:06 CET

Original text of this message