Relational ValueTrees?


#1

Are ValueTrees hip enough to be a fake database? I’d like to have:

Presentation 1

  • name
  • etc
  • Presenters
    • a
    • b
      Presentation 2
  • name
  • etc
  • Presenters
    • b
    • c

Where a, b, c are links to another valuetree with the presenter’s info, and so on. Is that possible?

What would happen when I save that to XML?

Bruce


#2

Well you can certainly stick all that data in one… Not sure whether I’d call it a database though, I don’t know if they’ll scale very well to millions of records!


#3

And the ‘a, b, c’ ValueTrees will point at the Presenter ValueTree (or the same underlying values), right?

That’s awesome. And thanks for being so responsive on this forum.

Don’t need millions, BTW, more like 30 or so. I’m just using it as a data source for main and detail list components.

Bruce


#4

…no, it’s not possible to do that, otherwise you could get all sorts of circular dependencies and reference counting problems. It’s like XML where you could either insert multiple copies of the source object, or do what you’d do in a database, and have some kind of index key which you look up in another list.


#5

Oh. That’s what I meant by relational. So, make one property a key and do a look-up into another ValueTree? That’s OK too.

I just had high hopes. Would something like weak references make it workable?

Bruce


#6

Not really sure how you’re imagining you’d create a weak reference. It’s a fundamental property of valuetrees that they can only have one parent - you can have multiple shared pointers to the same valuetree from your own data structures, but not from a parent valuetree.


#7

That’s what I was wondering - whether a ‘property’ of a ValueTree could be a weak pointer to another ValueTree. Avoiding the circular reference maybe.

But I hadn’t really looked at it - you mentioned circular references, and I thought I remembered you adding weak references somewhere. No problem - I’ll use an ID property.

Bruce