![]() ![]() In essence there is a fine balance on whether to embed related objects within one another or reference them by ID, and as most things in modelling there is not a one-stop solution on how to make this decision. Handling inter-aggregate relationships is more difficult than intra-aggregate ones: joins are not supported directly inside the kernel, but are managed in the application code or with the somewhat complex aggregation pipeline framework. it can hold nested lists, dictionaries or other composite types.Ītomicity is only supported within the contents of a single aggregate in other words the aggregate forms the boundary of an ACID operation (read more on the MongoDB manual). An aggregate is a collection of data that we interact with as a unit, and normally has more complex structure than a traditional row/record i.e. If you have any OOP experience, you must have come across in your career, Eric Evan’s classic book Domain Driven Design that introduces the aggregate models. To Embed or Not to Embed: That is The Question! When the entire collection is migrated, we can replace our application code to truly forget the old field.ĭatabase design is not something that is written in stone and schema changes can be vexing (if not paralysing) in legacy tabular databases, so the polymorphic feature of MongoDB is very powerful indeed. Once the application is updated to handle the absence of a field, we can migrate the collection in question in the background while the application is still running (assuming there is more than a single node involved). In MongoDB however, backwards compatibility comes out of the box, so developers account for these changes in the server-side code itself. Some ALTER commands executed on large tables can even take days to complete… With continuous deployment (CD) taking care of the application side of the release, the most time consuming task, requiring lengthy downtime, is pinned down to the database migration. The Achilles heel of a tabular schema that has been carefully engineered to be normalised by eliminating redundancy is that a small change to one table can cause a ripple of changes across the database and can spill into the server-side application code too.Ī typical approach is to stop the application, take a backup, run complex migration scripts to support the new schema, release the new version of the application to support the new schema and restart the application. ![]() The only thing constant in life is change - this certainly holds true to a database schema and it often poses challenges and a few headaches when it comes to traditional relational database systems. This option solves the redundancy issue, but still the query can get complex.Īs you can see there is a lot more code involved than in a polymorphic MongoDb collection! Schema Evolution
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |