Tuesday, February 14, 2023

CST363 Week 6

Compare MongoDB with MySQL. What are some similarities? What are some differences? When would you choose one over the other?

MySQL and MongoDB have similar concepts for structuring data. “Tables” and “rows” in MySQL become “collections” and “documents” in MongoDB. The major difference between MySQL’s tables/rows and MongoDB’s collections/documents is the flexibility of the schema. In MySQL, the schema needs to be strictly defined before the database can be created, and any data inputted. On the other hand, in MongoDB there is no formal schema – collections can be created, and documents inserted at any point, and with any structure. This fact gives MongoDB a major advantage when working with non-uniform structures. For example, consider a digital storefront – products will have many unique attributes associated with them, which would be difficult to capture efficiently in a traditional RDBMS. MongoDB can store these non-uniform attributes with ease, as it does not need to conform to a universal schema.

Additionally, MongoDB lends itself well to horizontal scaling and sifting through large amounts of data, due to the denormalized nature of the data. While RDBMS models can scale to a certain extent, it can be difficult to match the capabilities of NoSQL systems.

MySQL is applicable for well-defined, uniform data sets until “massive” amounts of data is concerned, where normalization becomes a prohibitive performance penalty. At this stage the slowdowns can be abated by denormalizing the data. The main advantage of RDBMS systems like MySQL is the Structured Query Language, which provides a simple means of performing queries. An example of an ideal RDBMS-implementation would be a user login / account system.