home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / interpre / proxy / rdb.prx < prev    next >
Text File  |  1994-01-29  |  1KB  |  25 lines

  1. // Sherlock Holmes relational database
  2.  
  3. struct crim {victim, crime, criminal, location;};
  4. struct murd {victim, weapon, motive;};
  5. crimes = {new crim("Phelps","robbery","Harrison","London"),
  6.         new crim("Drebber","murder","Hope","London"),
  7.         new crim("Sir Charles","murder","Stapleton","Devonshire"),
  8.         new crim("Lady Eva","blackmail","Milverton","London"),
  9.         new crim("Brunton","murder","Howells","West Sussex")};
  10. murders = {new murd("Drebber","poison","revenge"),
  11.        new murd("Sir Charles","hound","greed"),
  12.        new murd("Brunton","burial-alive","passion")};
  13. // Find the crimes of murder
  14. murder_crimes = {x:x<-crimes;x.crime=="murder"};
  15. // Find what murders occured in London
  16. london_murder_crimes = {x:x<-murder_crimes;x.location == "London"};
  17. // Project victim and criminal from above table
  18. london_murder_victims = {[x.victim,x.criminal]:x<-london_murder_crimes};
  19. // Find the criminals who either committed a murder by poisoning or
  20. // committed a non-murder
  21. criminals = {x.criminal:x<-crimes;x.crime != "murder"} U
  22.             {x.criminal:x<-crimes,y<-murders;(x.victim == y.victim)
  23.                         && (y.weapon == "poison")};
  24. end
  25.