Добрый день. Недавно начал использовать MongoDb и возник вопрос о денормализации.
ВводныеMediaCollection{
"_id": ObjectId("5584367e44ae3e41ad5481a3"),
"createdAt": ISODate("2015-06-19T15:34:22.927Z"),
"title" : "CD",
"properties": [
{"title": "format", value: "digital"},
{"title": "material", value: "plastic"}
]
}
{
"_id": ObjectId("5584367e44ae3e41ad5481a4"),
"createdAt": ISODate("2015-06-19T15:34:22.927Z"),
"title" : "Vinyl",
"properties": [
{"title": "format", "value": "analog"},
{"title": "material", "value": "vinyl"},
{"title": "size", "value": "12in"},
]
}
MusicCollection{
"_id": ObjectId("5584367e44ae3e41ad5481a8"),
"createdAt": ISODate("2015-06-19T15:34:22.927Z"),
"artist" : "Pink Floyd",
"title": "The Wall",
"properties": [
{"title": "year", value: "1988"},
{"title": "style", value: "Rock"}
],
"media": {
"_id": ObjectId("5584367e44ae3e41ad5481a4"),
"createdAt": ISODate("2015-06-19T15:34:22.927Z"),
"title" : "Vinyl",
"properties": [
{"title": "format", "value": "analog"},
{"title": "material", "value": "vinyl"},
{"title": "size", "value": "12in"},
]
}
}
Вопросы:
1. Нормальна ли такая сильная денормализация для MongoDb?
2. Нормально ли при изменении какого-либо документа в MediaCollection делать update поля media во всех записях MusicCollection?