Defining Complex Data Using Decision Tables - Gnorion/BizVR GitHub Wiki
Defining Complex Data Using Decision Tables
How would we define more complex data structures?
For example suppose we have a collection of children each of whom has a collection of toys. In json this might look like:
{"CHILDREN":[
{"name":"Billy","age":9,
"TOYS":[
{"color":"red","size":"small","shape":"square"},
{"color":"green","size":"small","shape":"square"}]
},
{"name":"Mary","age":7,
"TOYS":[
{"color":"blue","size":"large","shape":"round"},
{"color":"blue","size":"large","shape":"square"}]
}
]
}
How can we define this kind of nested structure using tables?
We can do it with three tables:
The first table creates the children:
TOYS is left empty since its a collection that will be filled in by a subsequent table.
The other two tables fill in the details of the toys for each child.
NOTE: You can also combine Billy and Mary into a single table if you prefer
We can also add a table for additional collections that belong to the CHILDREN (for example FRIENDS)
To get this json
{"CHILDREN":[
{"name":"Billy","age":9,
"TOYS":[
{"color":"red","size":"small","shape":"square"},
{"color":"green","size":"small","shape":"square"}],
"FRIENDS":[{"name":"Jimmy"}]
},
{"name":"Mary","age":7,
"TOYS":[
{"color":"blue","size":"large","shape":"round"},
{"color":"blue","size":"large","shape":"square"}],
"FRIENDS":[{"name":"Jenny"},{"name":"Sarah"}]
}
]
}