dbTalk Databases Forums  

Demo: Modelling Product Sales

comp.databases.object comp.databases.object


Discuss Demo: Modelling Product Sales in the comp.databases.object forum.



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

Default Demo: Modelling Product Sales - 12-14-2004 , 08:30 PM






The XDb2 script below models a single and a daily sale of products at
WalMarts in different cities. Each product has multiple classifications
and properties such as manufacturer, flavor, cost, etc. The individual
sale records date/time, price, quantity, customer, etc. A complex query
to find the individual sale is shown near end of script. See
www.xdb2.com/Example/Ex115.asp for details.


// Create classes to categorize things
CREATE *store.item ~in = dir;
CREATE *city.item ~in = dir;
CREATE *state.item ~in = dir;

CREATE *product.item ~in = dir;
CREATE *produce.item ~in = dir;
CREATE *medicine.item ~in = dir;
CREATE *headache remedy.item ~in = dir;
CREATE *cold medicine.item ~in = dir;

CREATE *mfg.item ~in = dir;
CREATE *flavor.item ~in = dir;
CREATE *cost.item ~in = dir;
CREATE *price.item ~in = dir;

CREATE *sale.item ~in = dir;
CREATE *daily sale.item ~in = dir;
CREATE *individual sale.item ~in = dir;
CREATE *date.item ~in = dir;
CREATE *time.item ~in = dir;
CREATE *qty.item ~in = dir;
CREATE *memo.item ~in = dir;

// 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.item ~in = dir;
CREATE *mgr.item ~in = dir;
CREATE *customer.item ~in = dir;
CREATE *gender.item ~in = dir;
CREATE *age.item ~in = dir;
CREATE *ss#.item ~in = dir;

// 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.
// Finds sale of Nyquil to Bob at Walmart #2.
SELECT %.cls=sale & %.store=(%.city=(%.state=illinois) &
%.mgr=((%.cls=mgr & %.name=john).like=%)) & %.product=(%.cls=cold
medicine & %.mfg=pfizer) & %.customer=(%.gender=male);


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.