Forum BigDB Describing complex data relationships?

Discussion and help relating to the PlayerIO database solution, BigDB.

Describing complex data relationships?

Postby mrgreen » April 21st, 2011, 11:35 am

Hiya, I was wondering whats the best way of describing complex relationships between objects such the following:


var character1:Character = new Character();
character1.neighbours = new Dictionary();
character1.neighbours["1"] = new Character(); // create second character, in a dictionary on first one

character1.neighbours["1"].neighbours = new Dictionary(); // create the same type of dictionary on the second
character1.neighbours["1"].neighbours["1"] = character1; // second Character links back to character1



IE, to have nested structures where the nested elements give reference to each other? The BigDB seems to be "flat" ie, I can have nested Objects inside each other, but on the last line when I link back to character1, thats not really possible is it? IE, that cant be an actual reference to the character object we created in the first line?

Any tips or ideas??
mrgreen
 
Posts: 52
Joined: February 12th, 2011, 7:27 pm

Re: Describing complex data relationships?

Postby Oliver » April 28th, 2011, 9:47 am

YOu shouldn't have direct links from one object to another. Keep links via IDs:

ObjA = {
...
neighbours: [ 'ObjB' ]
}

ObjB = {
...
neighbours: [ 'ObjA' ]
}

Then you have to lazy load the neighbours as you use them. You can cache them as you load them in a dictionary though.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to BigDB



cron