Re: Data Model

From: JOG <jog_at_cs.nott.ac.uk>
Date: 5 Apr 2006 17:54:06 -0700
Message-ID: <1144284846.045619.184170_at_i40g2000cwc.googlegroups.com>


Neo wrote:
> > There are many Judges.
> > There are many Buildings.
> > There are many Locations inside buildings( such as floors ).
> > Each judge must reside at exactly one location.
> > A staff member has a name, phone number, and email.
> > Each judge has 6 staff members, one of each type:
> > Clerk, Assistant Clerk, Coordinator, Bailiff, and Court Reporter.
> >
> > I'm looking forward to seeing the different results.
>
> :) I am pretty sure you were not looking for results as different as
> this, but here it is to tickle your mind.

I wonder if the OP's mind has ever been tickled with a sledgehammer before?

>
> The script below populates an experimental db with the following
> persons: Judge Judy (phone# 333-5555, email j_at_aol.com &
> judgeJudy_at_law.com) who has following staff members: Clerk Clark (who
> has Assistant Ashley), Coordinator Colby, Bailiff Brandy and
> Court-Reporter Courtney each with various properties. Building
> CourtHouse1 has two floors. The first floor has room1. The second floor
> has room1 and room2. Various person are placed in different parts of
> CourtHouse1. The sample query (near end of script) finds a staff member
> of a judge whose assistant has a certain phone#. Data can be easily
> navigated when viewed in a tree just by clicking nodes (even though the
> underlying data doesn't necessarily have a tree structure); where as in
> RM, it will require one to join multiple tables. If requested, I can
> email the populated db/exe (188 kb zip file) so one can see for
> themselves. Note, it is a prototype so other features may not work.
> Note, I did not make bi-directional relationships (ie j_at_aol.com emailOf
> judy) to keep the example simple. One effect of creating bi-directional
> relationships would have been to allow user to effectively "walk up"
> any relationship while expanding tree nodes. Note, script expressions
> become more elaborate when dealing with multiple things with the same
> name.
>
> Unlike RMDBs, where one must first design a schema/structure to hold
> anticipated data, no schema is required before entering data in the
> experimental db. The reason is, it already starts with a very general
> schema that is capable of modelling most anything in a normalized
> manner. This is partially why unanticipated types of data can be added
> on the fly during execution without a design/compile phase. Db
> automatically normalizes data and maintains referential integrity.
> Other constraints, such as each person must have a phone number or 6
> staff members, need to be implemented at code level where as RMDBs can
> implement such basic constriants at db level.
>
> // Create a type named building.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'building'))
> (create dir item (it))
>
> // Create a type named floor.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'floor'))
> (create dir item (it))
>
> // Create a type named room.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'room'))
> (create dir item (it))
>
>
> // Create a type named person.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'person'))
> (create dir item (it))
>
> // Create a type named judge.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'judge'))
> (create dir item (it))
>
> // Create a type named staffMember.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'staffMember'))
> (create dir item (it))
>
> // Create a type named clerk.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'clerk'))
> (create dir item (it))
>
> // Create a type named assistant.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'assistant'))
> (create dir item (it))
>
> // Create a type named coordinator.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'coordinator'))
> (create dir item (it))
>
> // Create a type named bailiff.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'bailiff'))
> (create dir item (it))
>
> // Create a type named courtReporter.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'courtReporter'))
> (create dir item (it))
>
> // Create a type named phone#.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'phone#'))
> (create dir item (it))
>
> // Create a type named email.
> (create type instance (new))
> (create (it) name (findElseAdd name instance 'email'))
> (create dir item (it))
>
> // Create a verb instance named has.
> (create verb instance (new))
> (create (it) name (findElseAdd name instance 'has'))
>
>
> // Create a person/judge named Judy.
> (create person instance (new))
> (create judge instance (it))
> (create (it) name (findElseAdd name instance 'judy'))
> (create (it) phone# (findElseAdd phone# instance '333-5555'))
> (create (it) phone# (findElseAdd phone# instance 'JDG-JUDY'))
> (create (it) email (findElseAdd email instance 'j_at_aol.com'))
> (create (it) email (findElseAdd email instance 'judy_at_law.com'))
>
> // Create a person/staffMember/clerk named Clark.
> (create person instance (new))
> (create staffMember instance (it))
> (create clerk instance (it))
> (create (it) name (findElseAdd name instance 'clark'))
> (create (it) phone# (findElseAdd phone# instance '737-5588'))
>
> // Create a person/staffMember/clerk/assistant named Ashley.
> (create person instance (new))
> (create staffMember instance (it))
> (create clerk instance (it))
> (create assistant instance (it))
> (create (it) name (findElseAdd name instance 'ashley'))
> (create (it) phone# (findElseAdd phone# instance '737-5588'))
>
> // Create a person/staffMember/coordinator named Colby.
> (create person instance (new))
> (create staffMember instance (it))
> (create coordinator instance (it))
> (create (it) name (findElseAdd name instance 'colby'))
> (create (it) email (findElseAdd email instance 'colby_at_msn.com'))
>
> // Create a person/staffMember/bailiff named Brandy.
> (create person instance (new))
> (create staffMember instance (it))
> (create bailiff instance (it))
> (create (it) name (findElseAdd name instance 'brandy'))
> (create (it) phone# (findElseAdd phone# instance '919-9945'))
>
> // Create a person/staffMember/courtReporter named Courtney.
> (create person instance (new))
> (create staffMember instance (it))
> (create courtReporter instance (it))
> (create (it) name (findElseAdd name instance 'courtney'))
> (create (it) phone# (findElseAdd phone# instance '203-9898'))
> (create (it) email (findElseAdd email instance 'c_at_gov.org'))
>
> // Create judge judy's staffMembers.
> (create judy staffMember clark)
> (create judy staffMember ashley)
> (create judy staffMember colby)
> (create judy staffMember brandy)
> (create judy staffMember courtney)
>
> // Create Clark's assistant Ashley
> (create clark assistant ashley)
>
>
> // Create a building instance named CourtHouse1.
> (create building instance (new))
> (create (it) name (findElseAdd name instance 'courtHouse1'))
>
> // Create a floor instance named floor1
> // and make it part of courtHouse1.
> (create floor instance (new))
> (create (it) name (findElseAdd name instance 'floor1'))
> (create courtHouse1 has (it))
>
> // Create room instances named room1
> // and make it part of floor1.
> (create room instance (new))
> (create (it) name (findElseAdd name instance 'room1'))
> (create floor1 has (it))
>
>
> // Create a floor instance named floor2.
> // and make it part of courtHouse1.
> (create floor instance (new))
> (create (it) name (findElseAdd name instance 'floor2'))
> (create courtHouse1 has (it))
>
> // Create room instances named room1
> // and make it part of floor2.
> (create room instance (new))
> (create (it) name (findElseAdd name instance 'room1'))
> (create floor2 has (it))
>
> // Create room instances named room2
> // and make it part of floor2.
> (create room instance (new))
> (create (it) name (findElseAdd name instance 'room2'))
> (create floor2 has (it))
>
>
> // Create CourtHouse1's has reporter Courtney.
> (create courtHouse1 has courtney)
>
> // Create CourtHouse1's floor1's has Ashley.
> (create (relElem (select courtHouse1 has floor1))
> has
> ashley)
>
> // Create CourtHouse1's floor1's room1 has Clark.
> (create (relElem (select (relElem (select courtHouse1 has floor1))
> has
> room1))
> has
> clark)
>
> // Create CourtHouse1's floor2's room2's has Judge Judy.
> (create (relElem (select (relElem (select courtHouse1 has floor2))
> has
> room2))
> has
> judy)
>
> // Find a staff member of a judge
> // whose assistant has phone# 737-5588.
> // Displays clerk Clark.
> (msgbox (and (select (select judge instance *) staffMember *)
> (select * assistant (select * phone# 737-5588))))
Received on Thu Apr 06 2006 - 02:54:06 CEST

Original text of this message