Converting semi-structured data into relational data
As we saw in the previous exercise, semi-structured data is flexible and can accommodate any amount of densely or sparsely nested elements. However, in nested objects, it can be inferred that lower-level elements are attributes of their immediate parents.
Observe the following simplified example of semi-structured data with three levels of nesting and use the indentation to count the depth.
Figure 15.5 – Observing the number of nested levels in a semi-structured object
Here, we can see that a (ship) type, of depth 2
, is an attribute of ship
, which is a level-one attribute of the root object. By this logic, if we follow the levels of a semi-structured object to its maximum depth N, those elements become attributes of an entity N-1. Then, N-1 entities become attributes of N-2, repeating recursively until arriving at the root.
In the current example, boarding axe
and blunderbuss
become instances...