Database Reference
In-Depth Information
tion, the rolling down technique enforces only those rules present in the subtypes.
This could lead to a less flexible data model as we can no longer easily accom-
modate new subtypes without modifying the data model. If a new type of Title is
required in addition to PrintVersion and eBook , this would require effort to ac-
commodate.
Rollup . Rollup means rolling up the subtypes up into the supertype. The subtypes
disappear, and all attributes and relationships only exist at the supertype level.
Rolling up adds flexibility to the data model because new types of the supertype
can be added, often with no model changes. However, rolling up can also produce
a more obscure model as the audience for the model may not relate to the supertype
as well as they would to the subtypes. In addition, we can only enforce business
rules at the supertype level and not at the subtype level. For example, now
printVersionWeightAmount and the eBookDownloadSize are optional instead
of required. When we roll up, we often need a way to distinguish the original sub-
types from each other, so we frequently add a type column such as titleTypeCode .
EXERCISE 2: Subtyping in MongoDB
Translate the Author / Title subtyping example we just reviewed into three MongoDB doc-
uments (rolldown, rollup, and identity) using the sample data on the facing page. Refer to
Appendix A for the answer.
Author
authorTaxID authorFirstName authorLastName
22-5555555
Steve
Hoberman
Title
titleISBN
authorTaxID
titleName
subtitleName
titleRetailPrice
Data Modeling Made
Simple
A Practical Guide for Business and IT Pro-
fessionals
9780977140060
22-5555555
$44.95
Data Modeling for
MongoDB
Building Well-Designed and Supportable
MongoDB Databases
9781935504702
22-5555555
$39.95
Search WWH ::




Custom Search