Re: object algebra
From: Neo <neo55592_at_hotmail.com>
Date: 25 Feb 2004 17:09:33 -0800
Message-ID: <4b45d3ad.0402251709.7cc08a69_at_posting.google.com>
}
Date: 25 Feb 2004 17:09:33 -0800
Message-ID: <4b45d3ad.0402251709.7cc08a69_at_posting.google.com>
> And now please write a query that returns an aggregate age of all persons.
> In this schema with SQL, or with Neo's school science fair project.
// Psuedo code to calc age of all unique persons under selected node // Step thru unique descendant's of God
int ageTotal = 0;
int* pDesc_a[kMAX_TREE_DEPTH] = {pGod};
while (int i = T_Relatives(pDesc_a, kCREATURE, kUNIQUE)){
int* pThing = pDesc_a[i]; if (IsAncestorOf(pPersonCls, pThing)){ int* pAge = T_Property_get(pThing, pAgeCls); if (pAge){ sAge = T_Symbol_get(pAge); ageTotal = ageTotal + ConvertSymbolToInteger(sAge); } }
}
XDb1 has transitive closure.
For actual code to a related problem, see www.xdb1.com/Example/Ex075b.asp
Received on Thu Feb 26 2004 - 02:09:33 CET