dbTalk Databases Forums  

Demo: Db For Dummies

comp.databases.object comp.databases.object


Discuss Demo: Db For Dummies in the comp.databases.object forum.



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

Default Demo: Db For Dummies - 11-09-2004 , 09:31 PM






The XDb2 script below creates/queries a person named john with black
skin and red-blue hair; and a person named mary with smooth-white skin
and red, silky-smooth hair. A similar RM implementation might use
T_Person, T_Skin, T_Hair, T_Color and T_Texture. See
www.xdb2.com/example/ex005.asp for more details.

// Create person, skin, hair, color and texture classes
CREATE2 *person.cls = thing;
CREATE2 *skin.cls = thing;
CREATE2 *hair.cls = thing;
CREATE2 *color.cls = thing;
CREATE2 *texture.cls = thing;

// Create black skin
CREATE2 *;
CREATE2 it.cls = skin;
CREATE2 it.color = +black;

// Create smooth-white skin
CREATE2 *;
CREATE2 it.cls = skin;
CREATE2 it.color = +white;
CREATE2 it.texture = +smooth;

// Create red-blue hair
CREATE2 *;
CREATE2 it.cls = hair;
CREATE2 it.color = +red;
CREATE2 it.color = +blue;

// Create red, silky-smooth hair
CREATE2 *;
CREATE2 it.cls = hair;
CREATE2 it.color = +red;
CREATE2 it.texture = +silky;
CREATE2 it.texture = +smooth;

// Create a person named john
// with black skin and red-blue hair
CREATE2 *john.cls = person;
CREATE2 john.skin = (%.cls=skin & %.color=black);
CREATE2 john.hair = (%.cls=hair & %.color=red & %.color=blue);

// Create a person named mary
// with smooth-white skin and red, silky-smooth hair
CREATE2 *mary.cls = person;
CREATE2 mary.skin = (%.cls=skin & %.color=white & %.texture=smooth);
CREATE2 mary.hair = (%.cls=hair & %.color=red & %.texture=silky &
%.texture=smooth);

// Queries that find john
SELECT2 %.cls=person & %.hair=(%.color=blue);
SELECT2 %.cls=person & %.hair=(%.color=red & %.color=blue);
SELECT2 %.cls=person & %.skin=(%.color=black);
SELECT2 %.cls=person & %.skin=(%.color=black) & %.hair=(%.color=red &
%.color=blue);

// Queries that find mary:
SELECT2 %.cls=person & %.hair=(%.texture=silky);
SELECT2 %.cls=person & %.hair=(%.color=red & %.texture=silky);
SELECT2 %.cls=person & %.skin=(%.color=white & %.texture=smooth);
SELECT2 %.cls=person & %.hair=(%.color=red & %.texture=silky &
%.texture=smooth);

// Queries that find john and mary:
SELECT2 %.cls=person; // Any person
SELECT2 %.skin; // Any thing with skin
SELECT2 %.hair; // Any thing with hair
SELECT2 %.hair=(%.color=red); // Any thing with red hair

Reply With Quote
  #2  
Old   
Ed prochak
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-10-2004 , 02:21 PM






neo55592 (AT) hotmail (DOT) com (Neo) wrote in message news:<4b45d3ad.0411091931.9faa461 (AT) posting (DOT) google.com>...
Quote:
The XDb2 script below creates/queries a person named john with black
skin and red-blue hair; and a person named mary with smooth-white skin
and red, silky-smooth hair. A similar RM implementation might use
T_Person, T_Skin, T_Hair, T_Color and T_Texture. See
www.xdb2.com/example/ex005.asp for more details.

[]

Other than beating us over the head with your syntax, what is the
purpose of these posts?

No one but you seems to post any new threads on XDb2. Is this a subtle
set of SPAM postings?

Ed


Reply With Quote
  #3  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-10-2004 , 03:43 PM



ed.prochak (AT) magicinterface (DOT) com (Ed prochak) wrote:

Quote:
neo55592 (AT) hotmail (DOT) com (Neo) wrote in message news:<4b45d3ad.0411091931.9faa461 (AT) posting (DOT) google.com>...
The XDb2 script below creates/queries a person named john with black
skin and red-blue hair; and a person named mary with smooth-white skin
and red, silky-smooth hair. A similar RM implementation might use
T_Person, T_Skin, T_Hair, T_Color and T_Texture. See
www.xdb2.com/example/ex005.asp for more details.

[]

Other than beating us over the head with your syntax, what is the
purpose of these posts?

No one but you seems to post any new threads on XDb2. Is this a subtle
set of SPAM postings?
No, it is not subtle.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #4  
Old   
Mikito Harakiri
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-10-2004 , 04:28 PM



neo55592 (AT) hotmail (DOT) com (Neo) wrote in message news:<4b45d3ad.0411091931.9faa461 (AT) posting (DOT) google.com>...
<snip>

How about

"Person with uniqie hair color? That is, a person with a hair color
such that there doesn't exist anybody else with this color"

Next

"Find a person with most frequent hair color"

P.S. Are you seriously considering changing the name of your product?
How about "Db for Idiots created by Dummies", or IDb (IdiotDb for
short).

Reply With Quote
  #5  
Old   
Neo
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-13-2004 , 10:43 PM



Quote:
"Person with uniqie hair color? That is, a person with a hair color
such that there doesn't exist anybody else with this color"
Above type queries can only be resolved via code/API at this time. The
psuedo code below solves similar but simpler case:

// Loop thru hair instances
while (hairX = X2(%.cls=hair)){
// Loop thru persons whose hair property is hairX
cntr = 0;
while (sub = X2("%.hair=hairX & %.cls=person")){
++cntr;
}

// Print person with unique hair
if (cntr == 1){
print("%s's hair is uniquely %s"), sub, hairX);
}
}


Quote:
"Find a person with most frequent hair color"
// Loop thru hair instances
mostCmnHair = NULL;
mostCmnHairCntr = 0;
while (hairX = X2("%.cls = hair")){
// Loop thru persons whose hair property is hairX
cntr = 0;
while (sub = X2("%.hair = hiarX & %.cls=person")){
++cntr;
}

// Store current hair if more common than prior
if (cntr > mostCmnHairCntr){
mostCmnHair = hairX;
mostCmnHairCntr = cntr;
}
}

// Print persons with most common hair
while (personX = X2("%.cls=person & %.hair=mostCmnHair")){
print("%s's hair is %s"), personX, mostCmnHair);
}


Reply With Quote
  #6  
Old   
--CELKO--
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-14-2004 , 09:38 AM



Quote:
Above type queries can only be resolved via code/API at this time.
The psuedo code below solves similar but simpler case:

Why would I want to write proceudral code for this things?

Quote:
"Person with uniqie hair color? That is, a person with a hair color
such that there doesn't exist anybody else with this color"

Or the hair occurs once in the population. Rewording makes life much
easier.

SELECT hair_color, MAX(person_id)
FROM Population
GROUP BY hair_color
HAVING COUNT (*) = 1;

And I agree with another comment; I do not see the point of these code
postings.


Reply With Quote
  #7  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-14-2004 , 10:45 AM



jcelko212 (AT) earthlink (DOT) net (--CELKO--) wrote:

Quote:
Above type queries can only be resolved via code/API at this time.
The psuedo code below solves similar but simpler case:

Why would I want to write proceudral code for this things?

"Person with uniqie hair color? That is, a person with a hair color
such that there doesn't exist anybody else with this color"
I have dark brown hair, and I also have grey hair. Then, there
are shades. I smell a bad model.

Quote:
Or the hair occurs once in the population. Rewording makes life much
easier.

SELECT hair_color, MAX(person_id)
FROM Population
GROUP BY hair_color
HAVING COUNT (*) = 1;

And I agree with another comment; I do not see the point of these code
postings.
Since I have dark brown hair and grey hair, what is my
hair_color?

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #8  
Old   
Alan
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-14-2004 , 12:17 PM




"Gene Wirchenko" <genew (AT) mail (DOT) ocis.net> wrote

Quote:
jcelko212 (AT) earthlink (DOT) net (--CELKO--) wrote:

Above type queries can only be resolved via code/API at this time.
The psuedo code below solves similar but simpler case:

Why would I want to write proceudral code for this things?

"Person with uniqie hair color? That is, a person with a hair color
such that there doesn't exist anybody else with this color"

I have dark brown hair, and I also have grey hair. Then, there
are shades. I smell a bad model.

Or the hair occurs once in the population. Rewording makes life much
easier.

SELECT hair_color, MAX(person_id)
FROM Population
GROUP BY hair_color
HAVING COUNT (*) = 1;

And I agree with another comment; I do not see the point of these code
postings.

Since I have dark brown hair and grey hair, what is my
hair_color?

Sincerely,

Gene Wirchenko

Here's something to think about:

You participate in a 1:M relationship with hair color. Joe Celko does not
participate at all




Reply With Quote
  #9  
Old   
Ja Lar
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-14-2004 , 12:59 PM




"Alan" <not.me (AT) uhuh (DOT) rcn.com> ...

Quote:
Here's something to think about:

You participate in a 1:M relationship with hair color. Joe Celko does not
participate at all
NULL? :-)




Reply With Quote
  #10  
Old   
Neo
 
Posts: n/a

Default Re: Demo: Db For Dummies - 11-14-2004 , 04:59 PM



Quote:
Above type queries can only be resolved via code/API at this time.
The psuedo code below solves similar but simpler case:

Why would I want to write proceudral code for this things?
For a problem that fits within RM's scope, one probably wouldn't want
to. The code demonstrates how to perform the query with the tools
currently available with XDb2.

Quote:
Person with uniqie hair color?

SELECT hair_color, MAX(person_id)
FROM Population
GROUP BY hair_color
HAVING COUNT (*) = 1;
First show the script to model the things as XDb2 did, that is without
NULLs and redundancy (I won't ask you to normalize down to symbols as
it would make RM's solution impractical).

Then add some carpets with hair properties as shown below. XDb2's
prior solutions will work with a minor change, which is to drop "&
%.cls=person" clause from the inner loop. In fact XDb2's solution will
then work even if we add dogs, cats, etc. I believe when we compare
XDb2 and RM's solutions under more complex situations, one will begin
to see the point.

CREATE2 *carpet.cls = thing;

CREATE2 *carpet1.cls = carpet;
CREATE2 carpet1.hair = (%.cls=hair & %.color=red & %.color=blue);

CREATE2 *carpet2.cls = carpet;
CREATE2 carpet1.hair = (%.cls=hair & %.color=red & %.texture=silky &
%.texture=smooth);


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.