Re: Storing data and code in a Db with LISP-like interface

From: Alvin Ryder <alvin321_at_telstra.com>
Date: 27 Apr 2006 23:06:43 -0700
Message-ID: <1146204403.356282.163280_at_g10g2000cwb.googlegroups.com>


Neo wrote:
> > Don't say flexible data, 'cause that's machine code.
>
> And I didn't :) Having a data model that provides a
> systematic/general/flexible method of representing things is different
> than the flexibililty afforded by machine code. If anyone would like to
> represent the data in the next Food Judge Example with machine code, I
> will take a serious look at it.
>

Neo,

Thank's for your reply. I understand your quest better now.

Years ago, when db's like Oracle costed big-bucks and I worked for cheap companies I was inspired to pursue something similar so I can empathize with your cause ;-)

Oddly enough after that time I worked for large Telco's which had Oracle and the such like at their finger tips, my interest in my db waned.

I think we agree machine code is not what we want, I was just trying to prompt you to spill the beans on your goals.

> > but I'm nervous about [dbd's] applicability to these groups.
>
> Representing things is the foundation for all computing including
> RMDBs, LISP, Prolog and OOP. Any limitations at this foundation
> eventually limits the full potential of tools built on top of it. One
> cannot faithfully process that which it can't represent.
>

I agree with representation (or data) is being vital but I also believe the computation side (code) is crucial. That's why I like OOP it honors both realms more or less equally ;-)

I'm an OOP fan but Programs=Algorithms+Data has never left me and neither has Algorithm=logic+control.

> > Perhaps I'm one still plugged into the Matrix,
> > Neo show me the truth what exactly are you trying to solve?
>
> To find the most general/flexible/systematic method of representing
> things. Since you (and LISP users) have experienced freedom that is
> difficult to achieve via RM or OOP, you are already nearly out of the
> Matrix :)
>

No worries. After 20 years of solid business and enteprise development I have returned to my roots. Games ;-) I hope you didn't mind my game-ishness.

> > I'm not saying go away, the world is not mine to dictate
> > but can you give us some OO connection to work with?
>
> The OO connection comes later which is to a great extent dependent on
> processing of data. Currently I am not focused on data processing. I
> want to first make sure I have the flexibility to represent anything in
> a systematic manner.
>

Ok but don't be surprised if the world needs to be changed inside out and upside down when the processing side comes into it.

The RM is powerful enough to represent business data, it rocks the business world but it utlimately lacks computational power and conviction to go all the way in every realm. From a games perspective the RM doesn't hold much value. And I have never seen SQL used by itself, it always needs something else to bail it out. (Yes I know RM does not equal SQL).

Anyway you've gotta start somewhere so let's leave these other things to later.

> > YES Prolog can do pretty well everything you've asked of it
> > but we're only repeating ourselves now.
>
> While there were a few minor issues, overall Prolog was able to
> represent most things in the dbd's Food Judge Example B. So now we
> extend to Example C.
>

Prolog is very cool and as Nick originally pointed out, you appear to be trying to reinvent it. My first post to your thread (which I don't think you saw) was an encouragement that advocated extending Prolog as a /possible/ way to fast track your pursuit.

> // Food Judge Example C
>
> // Similar to Judge Example B with following extenstions:
> // 1) Makes verbs like and likedBy reciprocals.
> // 2) Adds various textures and flavors to the entries.
> // 3) Adds johnathan as a second name for judge john.
> // 4) Adds contestant named john (aka johnny) who likes various
> entries.
> // 5) Adds spectator without a name who is age 28 and likes various
> entries.
> // 6) Adds judge john likes contestant john.
> // 7) Adds a few more queries.
> // Notes for Example B:
> // Function createWRR creates specified and reciprocal relationship.
> // Function verifyRel verifies transitive relationships.
>
> // Create a thing named person.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'person'))
>
>
> // Create a thing named judge.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'judge'))
>
> // Create a person/judge named john/johnathan.
> (createWRR person instance (new))
> (createWRR judge instance (it))
> (createWRR (it) name (findElseAdd word instance 'john'))
> (createWRR (it) name (findElseAdd word instance 'johnathan'))
>
>
> // Create a thing named contestant.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'contestant'))
>
> // Create a person/contestant named john/johnny.
> (createWRR person instance (new))
> (createWRR contestant instance (it))
> (createWRR (it) name (findElseAdd word instance 'john'))
> (createWRR (it) name (findElseAdd word instance 'johnny'))
>
>
> // Create a thing named spectator.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'spectator'))
>
> // Create a thing named age.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'age'))
>
> // Create a person/spectator without a name who is age 28.
> (createWRR person instance (new))
> (createWRR spectator instance (it))
> (createWRR (it) age (findElseAdd age instance '28'))
>
>
> // Create a verb named like.
> (createWRR verb instance (new))
> (createWRR (it) name (findElseAdd word instance 'like'))
>
> // Create a verb named likedBy.
> (createWRR verb instance (new))
> (createWRR (it) name (findElseAdd word instance 'likedBy'))
>
> // Relate verbs like and likedBy as reciprocals.
> // This data allows createWRR to create the reciprocal
> // relationships when either verb is specified.
> (create like reciprocal likedBy)
> (create likedBy reciprocal like)
>
>
> // Create a thing named texture
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'texture'))
>
> // Create textures: soft and crunchy.
> (createWRR texture instance (new))
> (createWRR (it) name (findElseAdd word instance 'soft'))
> (createWRR texture instance (new))
> (createWRR (it) name (findElseAdd word instance 'crunchy'))
>
>
> // Create a thing named flavor.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'flavor'))
>
> // Create flavors: sweet, sour and spicy.
> (createWRR flavor instance (new))
> (createWRR (it) name (findElseAdd word instance 'sweet'))
> (createWRR flavor instance (new))
> (createWRR (it) name (findElseAdd word instance 'sour'))
> (createWRR flavor instance (new))
> (createWRR (it) name (findElseAdd word instance 'spicy'))
>
>
> // Create a thing named entry (as in food entry).
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'entry'))
>
> // Create an entry named leftOver1 that is soft and spicy.
> (createWRR entry instance (new))
> (createWRR (it) name (findElseAdd word instance 'leftOver1'))
> (createWRR (it) texture soft)
> (createWRR (it) flavor spicy)
>
>
> // Create a thing named fruit.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'fruit'))
>
> // Create a fruit/entry named apple1 that is crunchy and sweet.
> (createWRR fruit instance (new))
> (createWRR entry instance (it))
> (createWRR (it) name (findElseAdd word instance 'apple1'))
> (createWRR (it) texture crunchy)
> (createWRR (it) flavor sweet)
>
>
> // Create a thing named vegetable.
> (createWRR thing instance (new))
> (createWRR (it) name (findElseAdd word instance 'vegetable'))
>
> // Create a vegetable/entry named broccoli1 that is crunchy.
> (createWRR vegetable instance (new))
> (createWRR entry instance (it))
> (createWRR (it) name (findElseAdd word instance 'broccoli1'))
> (createWRR (it) texture crunchy)
>
>
> // Create a fruit/vegetable/entry named tomato1 that is soft and
> sweet/sour.
> (createWRR fruit instance (new))
> (createWRR vegetable instance (it))
> (createWRR entry instance (it))
> (createWRR (it) name (findElseAdd word instance 'tomato1'))
> (createWRR (it) texture soft)
> (createWRR (it) flavor sweet)
> (createWRR (it) flavor sour)
>
>
> // Create judge john (aka johnathan)
> // likes leftOver1 and tomato1.
> (createWRR johnathan like leftOver1)
> or
> (createWRR (and (select judge instance *)
> (select * name (word1st 'john'))
> )
> like
> tomato1)
>
>
> // Create contestant john (aka johnny)
> // likes apple1 and tomato1.
> (createWRR johnny like apple1)
> (createWRR johnny like tomato1)
>
>
> // Create unnamed spectator likes broccoli1 and tomato1.
> (createWRR (and (select spectator instance *)
> (select * age 28))
> like
> broccoli1)
> (createWRR (and (select spectator instance *)
> (select * age 28))
> like
> tomato1)
>
>
> // Create judge john likes contestant john.
> // Several methods shown.
> (createWRR johnathan like johnny)
> or
> (createWRR johnny likedBy johnathan)
> or
> (createWRR johnathan
> like
> (and (select judge instance *)
> (select * name (word1st 'john'))))
>
>
> // What entries does judge john (aka johnathan) like?
> // Either of the below expressions
> // displays leftOver1 and tomato1
> // in 2 consecutive dialog boxes.
> (msgbox (and (select johnathan like *)
> (select entry instance *)))
>
> // Which fruit entries does contestant john (aka johnny) like?
> // Displays apple1 and tomato1.
> (msgbox (and (select johnny like *)
> (select fruit instance *)))
>
> // Which vegetable entries does spectator (of age 28) like?
> // Displays broccoli1 and tomato1.
> (msgbox (and (select (and (select spectator instance *)
> (select * age 28))
> like
> *)
> (select vegetable instance *)))
>
> // Find which fruit/vegetable entries does johnathan likes.
> // What does johnathan like which is a fruit and also a vegetable.
> // Displays tomato1.
> (msgbox (and (select johnathan like *)
> (select fruit instance *)
> (select vegetable instance *)))
>
>
> // Find things tomato1 is liked by.
> // Displays john/johnathan, john/johnny and person/spectator/28.
> (msgbox (select tomato1 likedBy *))
>
>
> // Find persons who likes cruchy vegetables.
> // Note spectator like broccoli which is crunchy.
> // Displays person/spectator/28
> (msgbox
> (and (select person instance *)
> (select * like (and (select vegetable instance *)
> (select * texture crunchy)))))
>
>
> // Which person likes something that is both a fruit and vegetable?
> // Displays john/johnathan, john/johnny and person/spectator/28.
> (msgbox
> (and (select person instance *)
> (select * like (and (select vegetable instance *)
> (select fruit instance *)))))
>
> // Which entry do judges, contestants and spectators like?
> // Displays tomato1.
> (msgbox (and (select entry instance *)
> (select (select judge instance *) like *)
> (select (select contestant instance *) like *)
> (select (select spectator instance *) like *)))
>
> // Which person likes another person who likes a fruit/vegetable entry?
> // Note that johnathan likes johnny who likes tomato1.
> // Displays john/johnnathan.
> (msgbox
> (and
> (select person instance *)
> (select *
> like
> (and (select person instance *)
> (select *
> like
> (and (select vegetable instance *)
> (select fruit instance *)))))))
>
> // Which person likes something which likes something that is soft,
> sweet/sour?
> // Note that johnathan likes johnny who likes tomato1 which is soft.
> // Displays john/johnnathan.
> (msgbox
> (and (select person instance *)
> (select *
> like
> (select *
> like
> (and (select * texture soft)
> (select * flavor sweet)
> (select * flavor sour))))))
>
>
> // Verify Transitive Relationships:
>
>
> // Is person is a thing?
> // Displays true.
> (msgbox (verifyRel person class thing))
>
> // Is vegetable is a thing?
> // Displays true.
> (msgbox (verifyRel vegetable class thing))
>
> // Is tomato1 is a vegetable?
> // Displays true.
> (msgbox (verifyRel tomato1 class vegetable))
>
> // Is tomato1 is a fruit?
> // Displays true.
> (msgbox (verifyRel tomato1 class fruit))
>
> // Is tomato1 is a thing?
> // Displays true.
> (msgbox (verifyRel tomato1 class thing))
>
> // Is tomato1 is a person?
> // Displays false.
> (msgbox (verifyRel tomato1 class person))
>
>
> // Is judge is an instance of thing?
> // Displays true.
> (msgbox (verifyRel thing instance judge))
>
> // Is fruit is an instance of thing?
> // Displays true.
> (msgbox (verifyRel thing instance fruit))
>
> // Is tomato1 is an instance of vegetable?
> // Displays true.
> (msgbox (verifyRel vegetable instance tomato1))
>
> // Is tomato1 is an instance of fruit?
> // Displays true.
> (msgbox (verifyRel fruit instance tomato1))
>
> // Is tomato1 is an instance of thing?
> // Displays true.
> (msgbox (verifyRel thing instance tomato1))
>
> // Is tomato1 is an instance of person?
> // Displays false.
> (msgbox (verifyRel person instance tomato1))
>
>
> All these things/relationships are much easier to see, comprehend as a
> whole and navigate when viewed in dbd's tree view.

Neo I'm sorry, that little thing called day job plus wife and 3 kids are getting in my way so I will not have the time to provide you with detailed LISP and or Prolog equivalents. From what I've seen both can easily do the above (if that's any value to you?)

Meantime I can only encourage you to check them out yourself, you only need a small tutorial and a chapter or two. I found both languages very easy to learn. I can provide some decent references if you want them.

Cheers. Received on Fri Apr 28 2006 - 08:06:43 CEST

Original text of this message