| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Storing data and code in a Db with LISP-like interface
> Also I will be posting an updated Food Judge Example as it was a
> quickie and not fully commented.
Here it is. Fresh of the hard disk. Bon appétit! Oh, I renamed "type" to "thing", as it didn't seem to fool anybody into believing that dbd is just like RMDBs :) Also I classified john as judge, well since the example title says Food Judge and maybe later we want to add participants and spectators.
// Food Judge Example using dbd.
// Create a thing named person.
(create thing instance (new))
(create (it) name (findElseAdd word instance 'person'))
// Create a thing named judge.
(create thing instance (new))
(create (it) name (findElseAdd word instance 'judge'))
// Create a person/judge named john.
(create person instance (new))
(create judge instance (it))
(create (it) name (findElseAdd word instance 'john'))
// Create a verb named like.
(create verb instance (new))
(create (it) name (findElseAdd word instance 'like'))
// Create a thing named entry (as in food entry).
(create thing instance (new))
(create (it) name (findElseAdd word instance 'entry'))
// Create an entry named leftOver1.
(create entry instance (new))
(create (it) name (findElseAdd word instance 'leftOver1'))
// Create a thing named fruit.
(create thing instance (new))
(create (it) name (findElseAdd word instance 'fruit'))
// Create a fruit/entry named apple1.
(create fruit instance (new))
(create entry instance (it))
(create (it) name (findElseAdd word instance 'apple1'))
// Create a thing name vegetable.
(create thing instance (new))
(create (it) name (findElseAdd word instance 'vegetable'))
// Create a vegetable/entry named broccoli1.
(create vegetable instance (new))
(create entry instance (it))
(create (it) name (findElseAdd word instance 'broccoli1'))
// Create a fruit/vegetable/entry named tomato1.
(create fruit instance (new))
(create vegetable instance (it))
(create entry instance (it))
(create (it) name (findElseAdd word instance 'tomato1'))
// Create john likes lefover1.
(create john like leftOver1)
// Create john likes apple1.
(create john like apple1)
// Create john likes broccoli1.
(create john like broccoli1)
// Create john likes tomato1.
(create john like tomato1)
// Hmm, maybe we need to also classify john as a pig!
// Find which entries john likes. // Either of the below expressions // displays leftOver1, apple1, broccoli1, tomato1 // in 4 consecutive dialog boxes.
(select entry instance *)))
// Find which fruit entries john likes.
// Displays apple1 and tomato1.
(msgbox (and (select john like *)
(select fruit instance *)))
// Find which vegetable entries john likes.
// Displays broccoli1 and tomato1.
(msgbox (and (select john like *)
(select vegetable instance *)))
// Find which fruit/vegetable entries john likes.
// Displays tomato1 in a dialog box.
(msgbox (and (select john like *)
(select fruit instance *)
(select vegetable instance *)))
Received on Mon Apr 24 2006 - 22:13:18 CDT
![]() |
![]() |