Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Storing data and code in a Db with LISP-like interface

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

From: Nick Malik [Microsoft] <nickmalik_at_hotmail.nospam.com>
Date: Tue, 18 Apr 2006 23:13:34 -0700
Message-ID: <1cGdnfANts6ZSdjZRVn-ig@comcast.com>


"Neo" <neo55592_at_hotmail.com> wrote in message news:1145298018.123938.13480_at_i39g2000cwa.googlegroups.com...
>> ... calling one of us an idiot. Not sure who. :-)
>
> Well if you don't want the compliment, I'll take it :)

LOL
>
>> Prolog is not an inherently type-safe language ...
>
> This is slightly off-topic, but I am curious about your view:

These are good questions, but I'm not sure if you are asking me about my views on relational data management or on logical rules management. The difference is simple. Relational describes relationships like 'is a' and 'has a' and 'is defined by' while logical rules management simply states 'the relationship is what you define it to be'.

It has been well over a decade since I wrote Prolog code, so if someone reading this newsgroup knows Prolog and they see this, my sincere apologies. The concept is what I'm trying to convey.

I will answer your questions with statements that are (or resemble) Prolog.

>
> 1) What is the proper name of the relationship between person and John,
> person and Mary, fruit and apple, fruit and banana, etc. Ie, fill the
> verb in: person ____ john.

named_instance(john,person).
named_instance(mary,person).
subtype(apple,fruit).
subtype(banana,fruit).

>
> 2) What is the proper name of the reverse relationship between John and
> person, Mary and person, apple and fruit, banana and fruit, etc. Ie,
> fill the verb in: john ___ person.

? named_instance(john, A )

(to which the system responds)
A = person

(I skipped your question. The answer to the logic of your question is: I would consider john to be a named instance of the noun 'person').

>
> 3) Just as John and Mary "are" persons, and apple and banana "are"
> fruits, what are person and fruit?

person is a noun. fruit is a noun. In Prolog, they are atoms. They have no 'meaning' except as defined by their relationship with john and banana. (You will notice that I use lower case, even for proper names. In Prolog, lower case tokens are 'atoms' while a token that begins with a capital letter is a variable).

>
> 4) Supposing the answer to question 3 is xyz, what is the proper name
> of the relationship between xyz and person, xyz and fruit, etc?

not a sensible question in Prolog context. There is no notion of subtype or supertype. Only expression. Imagine that we are talking about Boolean logic. A or B. Is A a variable? If we say "A is a B and B is a C, therefore A is a C," we have defined the transitive property of 'is a'. Before making the statement, the verb 'is a' had no such property. The scope of this property may be quite limited. Prolog assumes this. Most data management languages have a great many meta-rules. Prolog does too, but they are not based on the data. They are, instead, based on the logic.

>
> 5) Supposing the answer to question 3 is xyz, what is the proper name
> of the reverse relationship between person and xyz, fruit and xyz, etc?
>

See above.

Let's say, in Prolog, you want to express the transitive nature of 'contains'. It could look like this:

contains(A, B) :- contains(A, X), contains(X, B).

Now let's establish some facts.

contains(cup, coin).
contains(bucket, cup).
contains(box, bucket).
contains(truck, box).
contains(ship, truck).

We are saying that the coin is in the cup is in the bucket is in the box is in the truck is in the ship.

Now, ask the question: is the coin in the truck?

? contains(truck, coin)

to which the system responds:
yes.
(or 'true.' Not sure anymore ;-).

It does it by comparing the predicate contains/2 to each of the rules in the system. There are six matching rules. One is an expression. The rest are facts. The comparison doesn't match one of the facts, so the expression is invoked. The expression says: any item is inside another item if you can find an intermediary where the item is in the intermediary and the intermediary is in the other item... RECURSIVE. Using a depth-first search, the system quickly finds that the coin is in a cup where a cup is in a bucket where a bucket is in a box where a box is in a truck, therefore the coin is in the truck.

The entire program is in this post. There is nothing else.

HTH,

-- 
--- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not 
representative of my employer.
   I do not answer questions on behalf of my employer.  I'm just a 
programmer helping programmers.
--
Received on Wed Apr 19 2006 - 01:13:34 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US