j n wrote:

I am trying to use subtables with metakit and python.
Unfortunately, the docs are scarce about that.

Let's say I want to create a subtable for every new
day for a person. How do I add a new subtable later w/out
having to redefine w/getas?

Can't be done. Changing structure goes through getas().


vw=db.getas("barney[date1[location:S],date2[location:S]]")
[...]
This creates and adds data to 2 subtables. If I want
to add a third date. Is there an easy way to just
append the subtable?

Solution: think different. Instead of varying the structure according to your data needs, starts with a structure which varies in rows. Introduce an extra level:


vw=db.getas("barney[dates[day:I,locations[name:S]]]]")

Then you can do:

vw[i].dates.setsize(30)

vw[i].dates[1].locations.append('home')
vw[i].dates[1].locations.append('bowling')
vw[i].dates[1].locations.append('home again')

vw[i].dates[2].locations.append('work')
vw[i].dates[2].locations.append('bowling')
vw[i].dates[2].locations.append('at the bar')

This three-level structure is not necessarily very efficient (lots and lots of tiny subviews can have a bit of overhead in space and time). If that turns out to be an issue, consider this structure instead:

vw=db.getas("barney[locations[day:I,name:S]]")

Then add pairs/tuples such as (1,'home') instead.

The general guideline in these suggestions is to freeze the horizontal dimension (data structures) at design time, and to vary the vertical dimension (row contents) at run time.

-jcw

_______________________________________________
metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to