Database Reference
In-Depth Information
{ _id : "modal-jazz" ,
name : "Modal Jazz" ,
parent : "bop" ,
...
}
Figure 5-1. A music classification hierarchy
While using such a schema is flexible, it only allows us to examine one level of hierarchy with
any given query. If we want to be able to instead query for all ancestors or descendants of a
category, it's better to store the ancestor list in some way.
One approach to this would be to construct the ID of a subcategory based on the IDs of its
parent categories:
{ _id : "ragtime:bop:modal-jazz" ,
name : "Modal Jazz" ,
parent : "ragtime/bop" ,
...
}
This is a convenient approach because:
▪ The ancestors of a particular category are self-evident from the _id field.
Search WWH ::




Custom Search