Re: Demo: Modelling Cost of Travel Paths Between Towns

From: Neo <neo55592_at_hotmail.com>
Date: 4 Dec 2004 12:46:10 -0800
Message-ID: <4b45d3ad.0412041246.53dc577d_at_posting.google.com>


> Does Nyquil have any attributes other than its name? I added some attributes (mfg, flavor, cost, price, etc). See below.

> How does one enter the fact that 179 units of Nyquil were sold > in the Cooperstown, NY store on Dec. 3rd. ? See daily sale at Walmart #1 near end of script.

> Having each sale as a separate entry is an option. See individual sale at Walmart #2 near end of script.

// Create classes to categorize things

CREATE *store.cls = thing;
CREATE *city.cls = thing;
CREATE *state.cls = thing;

CREATE *product.cls = thing;
CREATE *produce.cls = thing;
CREATE *medicine.cls = thing;

CREATE *headache remedy.cls = thing;
CREATE *cold medicine.cls = thing;
CREATE *mfg.cls = thing;
CREATE *flavor.cls = thing;
CREATE *cost.cls = thing;
CREATE *price.cls = thing;

CREATE *sale.cls = thing;
CREATE *daily sale.cls = thing;
CREATE *individual sale.cls = thing;
CREATE *date.cls = thing;
CREATE *time.cls = thing;

CREATE *qty.cls = thing;
CREATE *memo.cls = thing;

// Create Asprin

CREATE *asprin.cls = product;

CREATE asprin.cls = medicine;
CREATE asprin.cls = headache remedy;
CREATE asprin.mfg = +bayer;
CREATE asprin.cost = +1.00;

// Create Tylenol

CREATE *tylenol.cls = product;

CREATE tylenol.cls = medicine;
CREATE tylenol.cls = cold medicine;
CREATE tylenol.cost = +2.00;

// Create Nyquil

CREATE *nyquil.cls = product;

CREATE nyquil.cls = medicine;
CREATE nyquil.cls = headache remedy;
CREATE nyquil.cls = cold medicine;
CREATE nyquil.mfg = +pfizer;
CREATE nyquil.flavor = +cherry;
CREATE nyquil.cost = +3.00;

// Create Garlic

CREATE *garlic.cls = product;

CREATE garlic.cls = produce;
CREATE garlic.cls = headache remedy;
CREATE garlic.cls = cold medicine;
CREATE garlic.cost = +4.00;

// Create Ginger

CREATE *ginger.cls = product;

CREATE ginger.cls = produce;
CREATE ginger.cls = cold medicine;
CREATE ginger.cost = +5.00;

// Create classes for persons and properties

CREATE *person.cls = thing;
CREATE *mgr.cls = thing;
CREATE *customer.cls = thing;
CREATE *gender.cls = thing;
CREATE *age.cls = thing;
CREATE *ss#.cls = thing;

// Create John

CREATE *john.cls = person;
CREATE john.cls = mgr;

// Create Mary

CREATE *mary.cls = person;
CREATE mary.cls = mgr;

// Create John likes Mary

CREATE *like.cls = verb;
CREATE john.like = mary;

// Create Bob

CREATE *bob.cls = person;

CREATE bob.cls = customer;
CREATE bob.gender = +male;
CREATE bob.age = +35;
CREATE bob."ss#" = +111-22-3333;


// Create Cooperstown

CREATE *cooperstown.cls = city;
CREATE cooperstown.state = +new york;  

// Create Chicago

CREATE *chicago.cls = city;
CREATE chicago.state = +illinois;

// Create Walmart #1 managed by John

CREATE *walmart.cls = store;
CREATE *walmart #1.cls = walmart;
CREATE walmart #1.city = cooperstown;
CREATE walmart #1.mgr = john;

// Create Walmart #2 managed by Mary

CREATE *walmart #2.cls = walmart;
CREATE walmart #2.city = chicago;
CREATE walmart #2.mgr = mary;

// Record a daily sale of 179 units of Nyquil
// on Dec 3rd at Walmart #1

CREATE *;

CREATE it.cls = sale;
CREATE it.cls = daily sale;
CREATE it.store = walmart #1;
CREATE it.date = +12/3/04;
CREATE it.product = nyquil;
CREATE it.qty = +179;

// Record an individual sales of Nyquil
// on 12/3/04 12:34:45 at Walmart #2 to Bob.
CREATE *;

CREATE it.cls = sale;
CREATE it.cls = individual sale;
CREATE it.store = walmart #2;
CREATE it.date = +12/3/04;
CREATE it.time = +12:34:45;
CREATE it.product = nyquil;
CREATE it.price = +3.19;
CREATE it.qty = +1;
CREATE it.customer = (%.cls=person & %.cls=customer & %.name=bob 
                                   & %.age=35 & %."ss#"=111-22-3333);
CREATE it.memo = +an alien fell thru ceiling;

// Find a sale at a store in illinois
// where the store manager is liked by another manager named john
// and the cold medicine product sold was mfgd by pfizer
// and sold to a person who is male.

SELECT %.cls=sale & %.store=(%.city=(%.state=illinois) 
                  & %.mgr=((%.cls=mgr & %.name=john).like=%)) 
                  & %.product=(%.cls=cold medicine & %.mfg=pfizer) 
                  & %.customer=(%.gender=male);
                  

Please post RM's equivalent NULL-less/normalized schema/query. Received on Sat Dec 04 2004 - 21:46:10 CET

Original text of this message