Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How to find persons who like red fruits or crunchy veggies?

 
   Database Forums (Home) -> Object-Oriented RSS
Next:  Modelling Persons, Devices and Phone Numbers with..  
Author Message
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 1) Posted: Tue Nov 14, 2006 9:16 pm
Post subject: How to find persons who like red fruits or crunchy veggies?
Archived from groups: comp>databases>object, others (more info?)

The following dbd query finds persons who like either red fruits or
crunchy veggies:

(and (select person instance *)
(select * like (or (and (select fruit instance *)
(select * color red))
(and (select veggie instance *)
(select * texture crunchy))
)
)
)

What RMDB schema and SQL query will find the equivalent? Should I start
with T_Person, T_Fruit, T_Veggie, T_PLikeF, T_PLikeV ?

 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
kvnkrkptrck

External


Since: Jun 21, 2006
Posts: 25



(Msg. 2) Posted: Wed Nov 15, 2006 11:48 am
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In your language, can you query:
How many fruit colors are there? Which fruit color(s) is/are the most
liked? How many veggies are there that nobody likes?


Neo wrote:
> The following dbd query finds persons who like either red fruits or
> crunchy veggies:
>
> (and (select person instance *)
> (select * like (or (and (select fruit instance *)
> (select * color red))
> (and (select veggie instance *)
> (select * texture crunchy))
> )
> )
> )
>
> What RMDB schema and SQL query will find the equivalent? Should I start
> with T_Person, T_Fruit, T_Veggie, T_PLikeF, T_PLikeV ?

 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 3) Posted: Wed Nov 15, 2006 3:05 pm
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: comp>databases, others (more info?)

> In your language, can you query:
> How many fruit colors are there? [Yes]
> Which fruit color(s) is/are the most liked? [No]
> How many veggies are there that nobody likes? [No]

Currently dbd's NLI (SQL-type) interface implements very basic
functions such as create, select, update and delete (and a few others
listed at www.dbfordummies.com/NLI/function.asp).

Even modest functions such as MIN, MAX, etc would need to be
implemented by application interfacing to a db via API. See
www.dbfordummies.com/example/ex010b.asp which generates a nearest
common ancestor report for things in a hierarchy.

Below are the closest queries that dbd can perform via its NLI:

(; Count fruits)
(count (select fruit instance *))

(; Count colors for fruits)
(count (and (select color instance *)
(select (select fruit instance *) color *)))

(; Find veggies somebody likes)
(and (select veggie instance *)
(select (select person instance *) like *))
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
Aloha Kakuikanu

External


Since: Jun 14, 2006
Posts: 128



(Msg. 4) Posted: Wed Nov 15, 2006 4:27 pm
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: comp>databases>object, others (more info?)

wrote:
> In your language, can you query:
> How many fruit colors are there? Which fruit color(s) is/are the most
> liked? How many veggies are there that nobody likes?

How about relational division type of queries?

i) find all job applicants who have all the skills (or find pilots that
can fly all the airplans)

ii)
table sets (
set# integer,
element integer
)

e.g. {{1,2,3},{3,4}}
set# element
---- ---------
1 1
1 2
1 3
2 3
2 4

find the intersection of the sets (i.e. all the elements that belong to
all the sets).
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
michael

External


Since: May 13, 2005
Posts: 43



(Msg. 5) Posted: Wed Nov 15, 2006 7:50 pm
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Neo wrote:
> The following dbd query finds persons who like either red fruits or
> crunchy veggies:
>
> (and (select person instance *)
> (select * like (or (and (select fruit instance *)
> (select * color red))
> (and (select veggie instance *)
> (select * texture crunchy))
> )
> )
> )
>
> What RMDB schema and SQL query will find the equivalent? Should I start
> with T_Person, T_Fruit, T_Veggie, T_PLikeF, T_PLikeV ?

I like tomatoes. Imagine a world without them. No ketchup. No pizza
base. Are they fruit or veges? They're not especially crunchy though
anyway. What about red capsicums? Are they crunchy veges or fruit?
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
tonkuma

External


Since: Dec 21, 2004
Posts: 88



(Msg. 6) Posted: Wed Nov 15, 2006 11:08 pm
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Neo wrote:
> The following dbd query finds persons who like either red fruits or
> crunchy veggies:
>
> (and (select person instance *)
> (select * like (or (and (select fruit instance *)
> (select * color red))
> (and (select veggie instance *)
> (select * texture crunchy))
> )
> )
> )
>
> What RMDB schema and SQL query will find the equivalent? Should I start
> with T_Person, T_Fruit, T_Veggie, T_PLikeF, T_PLikeV ?
For what dbd schema did you isuued this query? Would you show me exact
definition of dbd schema?
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
Ed Prochak

External


Since: Jan 10, 2006
Posts: 117



(Msg. 7) Posted: Thu Nov 16, 2006 7:27 am
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Tonkuma wrote:
> Neo wrote:
> > The following dbd query finds persons who like either red fruits or
> > crunchy veggies:
> >
> > (and (select person instance *)
> > (select * like (or (and (select fruit instance *)
> > (select * color red))
> > (and (select veggie instance *)
> > (select * texture crunchy))
> > )
> > )
> > )
> >
> > What RMDB schema and SQL query will find the equivalent? Should I start
> > with T_Person, T_Fruit, T_Veggie, T_PLikeF, T_PLikeV ?
> For what dbd schema did you isuued this query? Would you show me exact
> definition of dbd schema?

Please don't encourage Neo. He has an experimental system he created
himself. It is non-relational and "nonredundant" in the extreme. (e.g.,
he attempts to store the word red only once, whether it is used as the
color of fruit to someones nickname or a terrorist status).

Do a google search in this group is you feel like browsing nonsense.
Ed

Beware, there be trolls around here.
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 8) Posted: Thu Nov 16, 2006 7:52 am
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> For what dbd schema did you issued this query?
> Would you show me exact definition of dbd schema?

Dbd's "schema" is approximately as follows:
A sheet of paper with infinite lines (limited by memory),
where each lines can have a sentence of any length (usually 3 words).

This "schema" permits the following example:

(new 'red 'color)
(new 'yellow 'color)
(new 'green 'color)

(new 'soft 'texture)
(new 'crunchy 'texture)

(new 'apple 'fruit)
(create apple color red)
(create apple texture crunchy)

(new 'banana 'fruit)
(create banana color yellow)
(create banana texture soft)

(new 'celery 'veggie)
(create celery color green)
(create celery texture crunchy)

(new 'zuchinni 'veggie)
(create zuchinni color green)
(create zuchinni texture soft)

(new 'tomato 'fruit 'veggie)
(create tomato color red)
(create tomato color yellow)
(create tomato color green)
(create tomato texture soft)

(new 'like 'verb)

(new 'john 'person)
(create john like banana)
(create john like celery)

(new 'mary 'person)
(create mary like apple)
(create mary like zuchinni)

(new 'bob 'person)
(create bob like banana)
(create bob like zuchinni)
(create bob like tomato)

(new 'sue 'person)
(create sue like banana)
(create sue like zuchinni)


(; Who likes red fruits or crunchy veggies?)
(; Finds john, mary and bob)
(and (select person instance *)
(select * like (or (and (select fruit instance *)
(select * color red))
(and (select veggie instance *)
(select * texture crunchy)))))


See www.dbfordummies.com/NLI/new.asp for details on new function.
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 9) Posted: Thu Nov 16, 2006 9:46 am
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> ... store the word red only once, whether it is used as the color of fruit to someones nickname or a terrorist status).

(new 'red 'color)
(new 'red 'person)
(new 'red 'terrorStatus)

(; Find the class of things named red)
(; Returns color, person and terrorStatus)
(select * instance (select * name 'red))

New function details at www.dbfordummies.com/nli/new.asp
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 10) Posted: Thu Nov 16, 2006 1:34 pm
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> find pilots that can fly all airplanes

How can I do this in SQL? Below script models the data in dbd, however
the query does not work (currently the function named ALL does not
exist).

(new 'fly 'verb)

(new 'jet1 'jet)
(new 'jet2 'jet)

(new 'pilot1 'pilot)
(create pilot1 fly jet1)

(new 'pilot2 'pilot)
(create pilot2 fly jet1)
(create pilot2 fly jet2)

(; Find pilots who fly all jets)
(; Does not work currently)
(and (select pilot instance *)
(select * fly (ALL (select jet instance *))))
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 11) Posted: Thu Nov 16, 2006 9:27 pm
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> find pilots that can fly all airplanes

Following example finds pilots that fly all jets using selectAll
function.

(new 'fly 'verb)

(new 'jet1 'jet)
(new 'jet2 'jet)

(new 'pilot1 'pilot)
(create pilot1 fly jet1)

(new 'pilot2 'pilot)
(create pilot2 fly jet1)
(create pilot2 fly jet2)

(; Find pilots who fly all jets)
(; Finds pilot2)
(and (select pilot instance *)
(selectAll * fly (select jet instance *)))

(new 'jet3 'jet)
(new 'pilot3 'pilot)
(create pilot3 fly jet1)
(create pilot3 fly jet2)
(create pilot3 fly jet3)

(; Find pilots who fly all jets)
(; Finds pilot3)
(and (select pilot instance *)
(selectAll * fly (select jet instance *)))

(new 'red 'color)
(create jet1 color red)

(new 'green 'color)
(create jet2 color green)

(new 'blue 'color)
(new 'purple 'color)
(create jet3 color blue)
(create jet3 color purple)

(; Find pilots who fly all jets that are red)
(; Finds pliot1, pilot2 and pilot3)
(and (select pilot instance *)
(selectAll * fly (and (select jet instance *)
(select * color red))))

(; Find pilots who fly all jets that are green)
(; Finds pilot2 and pilot3)
(and (select pilot instance *)
(selectAll * fly (and (select jet instance *)
(select * color green))))

(; Find pilots who fly all jets that are blue and purple)
(; Finds pilot3)
(and (select pilot instance *)
(selectAll * fly (and (select jet instance *)
(select * color blue)
(select * color purple))))

(; Find pilots who fly all jets that are red or green)
(; Finds pilot2 and pilot3)
(and (select pilot instance *)
(selectAll * fly (and (select jet instance *)
(select * color (or red green)))))
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 12) Posted: Fri Nov 17, 2006 4:10 pm
Post subject: Re: How to find persons who like red fruits or crunchy veggies? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> In your language, can you query:
> How many fruit colors are there?
> Which fruit color(s) is/are the most liked?
> How many veggies are there that nobody likes?

An updated example with min, max, sum, avg and count functions.

(; Create qty 28, 30, 35)
(new '25 'quantity)
(new '30 'quantity)
(new '35 'quantity)

(; Create a verb named age)
(new 'age 'verb)

(; Create a person named john whose age is 25)
(new 'john 'person)
(create john age 25)

(; Create a person named mary whose age is 30)
(new 'mary 'person)
(create mary age 30)

(; Create a person named bob whose age is 35)
(new 'bob 'person)
(create bob age 35)

(; Create a person named sue whose age is unknown)
(new 'sue 'person)

(; Count persons)
(; Returns qty instance named 4)
(count (select person instance *))

(; Count persons with age)
(; Returns qty instance named 3)
(count (and (select person instance *)
(select * age)))

(; Get minimum age of persons)
(; Returns qty instance named 25)
(min (select (select person instance *) age *))

(; Get maximum age of persons)
(; Returns qty instance named 35)
(max (select (select person instance *) age *))

(; Get sum of persons age)
(; Returns qty instance named 90)
(sum (select (select person instance *) age *))

(; Get average of persons age)
(; Returns qty instance named 30)
(avg (select (select person instance *) age *))

For details, see www.dbfordummies.com/example/ex045.asp
 >> Stay informed about: How to find persons who like red fruits or crunchy veggies? 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> Object-Oriented All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]