dbTalk Databases Forums  

Querying for Pilots Who Fly All Jets in dbd

comp.databases.object comp.databases.object


Discuss Querying for Pilots Who Fly All Jets in dbd in the comp.databases.object forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Neo
 
Posts: n/a

Default Querying for Pilots Who Fly All Jets in dbd - 11-17-2006 , 02:19 PM






This dbd example models pilots who fly jets.
Queries with selectAll find pilots who fly all jets.
For details, see www.dbfordummies.com/example/ex042.asp

(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 pilot1, 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)))))

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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.