Normalization and Denormalization of Data
Explore the concepts of data normalization and denormalization in database design, focusing on MongoDB’s NoSQL structure. Understand how to organize related data for efficient queries and updates by embedding documents or separating tables based on application needs.
We'll cover the following...
Database design
A properly-designed database schema is essential for our query’s effectiveness. It will reduce the amount of data retrieval code we’ll have to write to retrieve data from the database later. For example, there’s a relationship between the books and authors models of the online bookshop application. A book can be written by different authors and an author can also write different books. How this relationship is saved in the database depends on the type of queries we run.
MongoDB, which is a NoSQL database, doesn’t enforce a schema by default unlike SQL databases like Postgres and MySQL. In a relational database, data is separated into different tables and is retrieved by queries using join statements to link and pull data from the different tables. This isn’t the case for NoSQL databases, which favor saving all the information about a model in a single collection instead.
Data normalization
...