Databases Reference
In-Depth Information
"mw" : 32.1173
}
mw stands for “molecular weight.”
Silicon nitride might have a couple other properties, so its document would look
like this:
{
"name" : "silicon nitride",
"mw" : 42.0922,
"ΔfH°gas" : {
"value" : 372.38,
"units" : "kJ/mol"
},
"S°gas" : {
"value" : 216.81,
"units" : "J/mol×K"
}
}
MongoDB lets us store chemicals with any number or structure of properties, which
makes this application nicely extensible, but there's no efficient way to index it in its
current form. To be able to quickly search for any property, we would need to index
almost every key! As we learned in Chapter 5 , this is a bad idea.
There is a solution. We can take advantage of the fact that MongoDB indexes every
element of an array, so we can store all of the properties we want to search for in an
array with common key names. For example, with silicon nitride we can add an array
just for indexing containing each property of the given chemical:
{
"name" : "silicon nitride",
"mw" : 42.0922,
"ΔfH°gas" : {
"value" : 372.38,
"units" : "kJ/mol"
},
"S°gas" : {
"value" : 216.81,
"units" : "J/mol×K"
},
"index" : [
{"name" : "mw", "value" : 42.0922},
{"name" : "ΔfH°gas", "value" : 372.38},
{"name" : "S°gas", "value" : 216.81}
]
}
Silicon, on the other hand, would have a single-element array with just the molecular
weight:
{
"name" : "silicon",
"mw" : 32.1173,
 
Search WWH ::




Custom Search