dbTalk Databases Forums  

Demo: Var# of Properties with Var# of Values with XDb2

comp.databases.object comp.databases.object


Discuss Demo: Var# of Properties with Var# of Values with XDb2 in the comp.databases.object forum.



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

Default Demo: Var# of Properties with Var# of Values with XDb2 - 08-30-2004 , 11:34 AM






This XDb2 example (www.xdb2.com/Example/Ex109.asp) represents the
following things with variable number of properties and values:

wig1's color is red.
wig2's color is red, green AND texture is soft AND material is nylon.
wig3's texture is soft AND material is jute.

coat1's color is red.
coat2's texture is soft AND material is cotton.
coat3's color is green AND texture is smooth, supple.

/************************************************** ***
Below code shows how to create and query above things,
including all things that are red.
************************************************** ****/
// Create wig class
int* pWig = T_create();
T_Name_relate(&pWig, _T("wig"));
T_relate(&pWig, &pReCls_g, &pThing_g);

// Create coat class
int* pCoat = T_create();
T_Name_relate(&pCoat, _T("coat"));
T_relate(&pCoat, &pReCls_g, &pThing_g);

// Create color class
int* pColor = T_create();
T_Name_relate(&pColor, _T("color"));
T_relate(&pColor, &pReCls_g, &pThing_g);

// Create texture class
int* pTexture = T_create();
T_Name_relate(&pTexture, _T("texture"));
T_relate(&pTexture, &pReCls_g, &pThing_g);

// Create material class
int* pMaterial = T_create();
T_Name_relate(&pMaterial, _T("material"));
T_relate(&pMaterial, &pReCls_g, &pThing_g);

// Create wig1
// Its color is red.
int* pWig1 = T_create();
T_Name_relate(&pWig1, _T("wig1"));
T_relate(&pWig1, &pReCls_g, &pWig);
T_Val_relate(&pWig1, &pColor, _T("red"));

// Create wig2
// Its color is red, green AND texture is soft AND material is nylon.
int* pWig2 = T_create();
T_Name_relate(&pWig2, _T("wig2"));
T_relate(&pWig2, &pReCls_g, &pWig);
T_Val_relate(&pWig2, &pColor, _T("red"));
T_Val_relate(&pWig2, &pColor, _T("green"));
T_Val_relate(&pWig2, &pTexture, _T("soft"));
T_Val_relate(&pWig2, &pMaterial, _T("nylon"));

// Create wig3
// Its texture is soft AND material is jute.
int* pWig3 = T_create();
T_Name_relate(&pWig3, _T("wig3"));
T_relate(&pWig3, &pReCls_g, &pWig);
T_Val_relate(&pWig3, &pTexture, _T("soft"));
T_Val_relate(&pWig3, &pMaterial, _T("jute"));

// Create coat1
// Its color is red.
int* pCoat1 = T_create();
T_Name_relate(&pCoat1, _T("coat1"));
T_relate(&pCoat1, &pReCls_g, &pCoat);
T_Val_relate(&pCoat1, &pColor, _T("red"));

// Create coat2
// Its texture is soft AND material is cotton.
int* pCoat2 = T_create();
T_Name_relate(&pCoat2, _T("coat2"));
T_relate(&pCoat2, &pReCls_g, &pCoat);
T_Val_relate(&pCoat2, &pTexture, _T("soft"));
T_Val_relate(&pCoat2, &pMaterial, _T("cotton"));

// Create coat3
// Its color is green AND texture is smooth, supple.
int* pCoat3 = T_create();
T_Name_relate(&pCoat3, _T("coat3"));
T_relate(&pCoat3, &pReCls_g, &pCoat);
T_Val_relate(&pCoat3, &pColor, _T("green"));
T_Val_relate(&pCoat3, &pTexture, _T("smooth"));
T_Val_relate(&pCoat3, &pTexture, _T("supple"));

// Create relational expr to find things related to color AND texture
TCHAR sExpr[kStrSz_g+1] = _T("((wig)) ((color)) ((texture))");

// Loop thru things satisfying expression and print their full name.
// The loop below prints the following:
// "((wig))(wig2)(((color))(red))(((color))(green))(( (texture))(soft))
(((material))(nylon))"
#define aSz 255
int* pExpr1[aSz+1] = {NULL};
if (Z_parse_r(_T("(wig) ((color)) ((texture))"), pExpr1, aSz))
{return;}
while (int* pT=Z(pExpr1, TRUE)){
TCHAR sName[kStrSz_g+1] = _T("");
T_Name_get(pT, sName, kStrSz_g, TRUE);
TRACE(_T("%s\n"), sName);
}

// Loop thru things satisfying expression and print their full name.
// The loop below prints the following:
// "((coat))(coat3)(((color))(green))(((texture))(smo oth))(((texture))(supple))"
int* pExpr2[aSz+1] = {NULL};
if (Z_parse_r(_T("(coat) ((color)) ((texture))"), pExpr2, aSz))
{return;}
while (int* pT=Z(pExpr2, TRUE)){
TCHAR sName[kStrSz_g+1] = _T("");
T_Name_get(pT, sName, kStrSz_g, TRUE);
TRACE(_T("%s\n"), sName);
}

// Find all things that are red
// The loop below prints the following:
// "(wig1)((wig))(((color))(red))"
// "(wig2)((wig))(((color))(red))(((color))(green))(( (texture))(soft))
(((material))(nylon))"
// "(coat1)((coat))(((color))(red))"
int* pRed = AStr_getDefT(_T("red"));
int* pE1[32];
if (Expr_xVO_get_r(pColor, pRed, pE1)){return;}
while (int* pT=X2(pE1)){
TCHAR sName[kStrSz_g+1] = _T("");
T_Name_get(pT, sName, kStrSz_g, TRUE);
TRACE(_T("%s\n"), sName);
}

// Given wig1, print its info
// Prints "((wig))(wig1)(((color))(red))"
TCHAR sName[kStrSz_g+1] = _T("");
T_Name_get(pWig1, sName, kStrSz_g, TRUE);
TRACE(_T("%s\n"), sName);

// Given wig2, print its info
// Prints "((wig))(wig2)(((color))(red))(((color))(green))(( (texture))(soft))
(((material))(nylon))"
_tcscpy(sName, _T(""));
T_Name_get(pWig2, sName, kStrSz_g, TRUE);
TRACE(_T("%s\n"), sName);

// Given wig3, print its properties/values using alternate method
// "wig3's cls is wig."
// "wig3's name is wig3."
// "wig3's texture is soft."
// "wig3's material is jute."
// Loop thru wig3's properties and values
int* pE2[32];
Expr_S_getN_r(pWig3, pE2);
while (int* pN = X2(pE2)){
// Get property
int* pProp = N_getV(pN);

// Get value
int* pVal = N_getO(pN);

// Print "thingX's propY is valX."
TCHAR sThing[kStrSz_g+1] = _T("");
T_Name_get(pWig3, sThing, kStrSz_g);

TCHAR sProp[kStrSz_g+1] = _T("");
T_Name_get(pProp, sProp, kStrSz_g);

TCHAR sVal[kStrSz_g+1] = _T("");
T_Name_get(pVal, sVal, kStrSz_g);

TCHAR sSent[3*kStrSz_g+1] = _T("");
_stprintf(sSent, _T("%s's %s is %s."), sThing, sProp, sVal);
TRACE(_T("%s\n"), sSent);
}

Reply With Quote
  #2  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: Demo: Var# of Properties with Var# of Values with XDb2 - 08-30-2004 , 05:12 PM






On 30 Aug 2004 09:34:42 -0700, Neo wrote:

(snip)

Hi Neo,

You still owe me $1000.

http://tinyurl.com/yvm5g

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

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

Default Re: Demo: Var# of Properties with Var# of Values with XDb2 - 08-30-2004 , 09:44 PM



Quote:
You still owe me $1000.
Please post solution in original thread using RM Sol#1 or #2 to create
the hierarchal reports for the following without NULLs or redundancy:

Case1: God is the parent of an unnamed person. God is also the parent
of second person with three names (string 'john', integer 100, decimal
3.14).

Case2: john isa person. john's color is brown. mary isa person. mary's
color is brown. brown is a person.

Below are measurements made thus far using RM solutions that aren't as
generic or normalized as XDb1's. Note that XDb1's solution for
generating a small common ancestor report running on a 233 Mhz Pocket
PC is nearly twice as fast as that of a non-normalized, non-generic
Sql Server 2000 solution running on a 5.6 times faster 1,300 MHz
desktop.

Small Report Generation Summary (provided by Hugo)
---------------------------------------------------------------------
Solution Time(ms) Platform Notes
-------------- -------- ----------------- --------------------------
RM#1 SqlSrvr2K 14.3 1.3 Ghz PC Unnormalized, non-generic
RM#2 SqlSrvr2K 11.0 1.3 Ghz PC Unnormalized, non-generic
XDb1 4.4.7 16 1.3 Ghz PC Debug ver, norm and gener


Small Report Generation Summary (provided by Neo)
---------------------------------------------------------------------
Solution Time(ms) Platform Notes
------------- -------- ----------------- --------------------------
RM#1 SqlSrvr7 65.0 500 Mhz Server Unnormalized, non-generic
RM#2 SqlSrvr7 68.9 500 Mhz Server Unnormalized, non-generic
XDb1 4.5.7 1.632 500 Mhz Server Normalized, generic
XDb1 4.5.9 6.561 233 MHz PocketPC Normalized, generic


Large Report (28,940 rows) Generation Summary (provided by Neo)
200 Goat Hierarchy (5 generations x 40 goats/generation,
each goat having two parents, except 1st gen).
---------------------------------------------------------------------
Solution Time(sec) Platform Notes
------------- -------- ----------------- --------------------------
RM#5 SqlSrvr7 40.5 500 Mhz Server Unnormalized, non-generic
XDb1 4.5.7 2.9 500 Mhz Server Normalized, generic
XDb1 4.5.9 16.971 233 Mhz PocketPC Normalized, generic


Larger Report (276,620 rows) Generation Summary (provided by Neo).
400 Goat Hierarchy (10 gen x 40 goats/gen),
---------------------------------------------------------------------
Solution Time(ms) Platform Notes
------------- -------- ----------------- --------------------------
RM#5 SqlSrvr7 105 min 500 Mhz Srvr, NT Avg of 2 runs, UnNrm,UnGen
XDb1 4.5.10 44 min 500 Mhz Srvr, NT Avg of 2 runs, Norm, gener
XDb1 4.5.10 57 min 450 Mhz PC, 98 1 run, Normalized, generic
XDb1 4.5.10 195 min 233 Mhz PocketPC 1 run, Normalized, generic


Reply With Quote
  #4  
Old   
Nick Landsberg
 
Posts: n/a

Default Re: Demo: Var# of Properties with Var# of Values with XDb2 - 08-30-2004 , 10:00 PM



Neo wrote:

[Apples and Oranges comparisons]

Aaaaaarrrrrghhhhhh! Not again!


--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch

Reply With Quote
  #5  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: Demo: Var# of Properties with Var# of Values with XDb2 - 08-31-2004 , 03:15 AM



On 30 Aug 2004 19:44:08 -0700, Neo wrote:

Quote:
Please post solution in original thread using RM Sol#1 or #2 to create
the hierarchal reports for the following without NULLs or redundancy:
(snip)

Hi Neo,

I've already told you (numerous times) that I won't enter any new
challenges until you pay me the $1000 I won in your previous challenge.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)


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

Default Re: Demo: Var# of Properties with Var# of Values with XDb2 - 08-31-2004 , 11:42 AM



Quote:
... I won in your previous challenge.
Small Report Generation Summary
---------------------------------------------------------------------
Solution Time(ms) Platform Notes
-------------- -------- ----------------- --------------------------
RM#2 SqlSrvr2K 11.0 1.3 Ghz PC Unnormalized, non-generic


Small Report Generation Summary
---------------------------------------------------------------------
Solution Time(ms) Platform Notes
------------- -------- ----------------- --------------------------
RM#2 SqlSrvr7 68.9 500 Mhz Server Unnormalized, non-generic
XDb1 4.5.7 1.632 500 Mhz Server Norm to atomic symbols, generic
XDb1 4.5.9 6.561 233 MHz PocketPC Norm to atomic symbols, generic


Reply With Quote
  #7  
Old   
Laconic2
 
Posts: n/a

Default Re: Demo: Var# of Properties with Var# of Values with XDb2 - 08-31-2004 , 02:05 PM




"Hugo Kornelis" <hugo (AT) pe_NO_rFact (DOT) in_SPAM_fo> wrote


Quote:
I've already told you (numerous times) that I won't enter any new
challenges until you pay me the $1000 I won in your previous challenge.
I think we all learned the last time that it's not a good idea to enter a
contest where one of the contestants is the judge.




Reply With Quote
  #8  
Old   
Bob Nemec
 
Posts: n/a

Default Re: Demo: Var# of Properties with Var# of Values with XDb2 - 08-31-2004 , 03:26 PM



On 30 Aug 2004 19:44:08 -0700, Neo wrote:

Quote:
You still owe me $1000.

Please post solution in original thread using RM Sol#1 or #2 to create
the hierarchal reports for the following without NULLs or redundancy:
Why?


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.