Re: why hierarchy?
Date: 26 Jul 2006 09:02:35 -0700
Message-ID: <1153929755.298416.183230_at_75g2000cwc.googlegroups.com>
> > example/ex007.asp > > One hiearchy is talking about ancestors of persons, the other about origins of persons. The hierarchies record the persons twice.
> Relations would record them once and record ancestors once and record origins once.
True, if the proper schema is used.
> Many problems with hierarchies - here's one: if a user is aware of only one hierarchy and discovers that there is no such person as John and 'deletes' him, the other hierarchy is now wrong, as is the DB.
> > To verify which method's underlying data model is more general, one can observe the impact on existing schema/data/query when meeting future unknown data requirements (to be proposed by someone else). Would someone be willing to engage in this trivial example? > > It does seem trivial.
(; Create a class directory item and name it age)
(new)
(create clsDir item (it))
(create (it) name (word+ 'age))
(; Create a main directory item and name it god)
(new)
(create dir item (it))
(create (it) name (word+ 'god))
(; Create a class directory item and name it person)
(new)
(create clsDir item (it))
(create (it) name (word+ 'person))
(; Create a person named adam)
(new)
(create person instance (it))
(create (it) name (word+ 'adam))
(; Create a person named eve)
(new)
(create person instance (it))
(create (it) name (word+ 'eve))
(; Create a person named john whose age is 35)
(new)
(create person instance (it))
(create (it) name (word+ 'john))
(create (it) age (val+ '35))
(; Create a person named mary whose age is 25)
(new)
(create person instance (it))
(create (it) name (word+ 'mary))
(create (it) age (val+ '25))
(; Create god's children hierarchy)
(; Note: verbs parent/child are system verbs)
(createWRR god child adam)
(createWRR god child eve)
(createWRR adam child john)
(createWRR adam child mary)
(createWRR eve child john)
(createWRR eve child mary)
(; Create a main directory item and name it universe)
(new)
(create dir item (it))
(create (it) name (word+ 'universe))
(; Create a class directory item and name it planet)
(new)
(create clsDir item (it))
(create (it) name (word+ 'planet))
(; Create planet mars)
(new)
(create planet instance (it))
(create (it) name (word+ 'mars))
(; Create planet venus)
(new)
(create planet instance (it))
(create (it) name (word+ 'venus))
(; Create universe's part hierarchy)
(; Note: verbs asm/part are system things)
(createWRR universe part mars)
(createWRR universe part venus)
(createWRR mars part john)
(createWRR venus part mary)
(; Find eve's children)
(; Finds john and mary)
(select eve child *)
(; Find john's parents)
(; Finds adam and eve)
(select john parent *)
(; Find adam's children that are part of mars)
(; Finds john)
(and (select adam child *)
(select mars part *))
(; Find eve's children that are part of a planet)
(; Finds john and mary)
(and (select eve child *)
(select (select planet instance *) part *))
(; Find god's grandchildren that are part of a planet)
(; Finds john and mary)
(; Note: they are found twice since each has two parents)
(and (select (select god child *) child *)
(select (select planet instance *) part *)) Received on Wed Jul 26 2006 - 18:02:35 CEST