Answer the question
In order to leave comments, you need to log in
Is this denormalization normal in Mongodb?
Good afternoon. Recently started using MongoDb and got a question about denormalization.
Introductory
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"},
]
}
{
"_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"},
]
}
}
Answer the question
In order to leave comments, you need to log in
This is too much, IMHO, in this case it is better to add ObjectID from MediaCollection.
I don’t see any advantages in such a decomposition, but there are a lot of problems.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question