Computer Science BS Journal (CST363) : Week 7
This week we installed and used MongoDB. It was super new to me and I haven't really used the command prompt very much so when I was running into errors while trying to load my JavaScript file I got a bit irritated. I got it working eventually after realizing I had to move my file to a different directory and type out the full path when trying to load it. That solved all my issues. I followed the same steps when loading the other two files provided for the lab and it went smoothly. Here are some things I noticed when comparing Mongo DB with MySQL.
Similarities
-
Database Management: Both are database management systems used to store, retrieve, and manage data.
-
Cross-Platform: Both are cross-platform and run on Linux, Windows, and macOS.
-
Indexing: Both support indexing for faster queries.
-
Replication: Both support data replication for high availability.
-
Security: Both offer authentication, authorization, and encryption features.
-
Community and Support: Each has strong community support, robust documentation, and commercial services available.
Differences
Feature | MongoDB (NoSQL) | MySQL (Relational SQL) |
---|---|---|
Data Model | Document-based (JSON-like BSON) | Table-based (rows and columns) |
Schema | Schema-less or dynamic schema | Rigid schema (predefined tables) |
Query Language | MongoDB Query Language (MQL) | Structured Query Language (SQL) |
Transactions | Supports multi-document transactions (since v4.0) | ACID-compliant transactions by default |
Joins | Limited support via $lookup | Strong support for joins across tables |
Scalability | Built for horizontal scaling (sharding) | Vertical scaling (with some clustering) |
Use Case Fit | Unstructured/semi-structured data | Structured data with strong relationships |
Storage Format | BSON (binary JSON) | Traditional relational formats |
When to Choose Each
Choose MongoDB when:
-
You need to store unstructured or semi-structured data.
-
The schema changes frequently or is undefined at design time.
-
You are building a modern web/mobile app with fast iterations.
-
Horizontal scalability is a priority (e.g., large-scale analytics, IoT, big data).
-
You're working with nested documents or arrays (e.g., catalog data, user profiles).
Choose MySQL when:
-
Data integrity and consistency are critical (banking, e-commerce).
-
You need complex queries with joins and transactions.
-
You have a well-defined schema and relationships.
-
You are using legacy systems or applications built with a traditional LAMP stack.
-
You require industry-standard tools and mature SQL support.
Summary
Use Case | Best Option |
---|---|
Highly structured data | MySQL |
Flexible, evolving schema | MongoDB |
Complex joins and transactions | MySQL |
Horizontal scalability | MongoDB |
Fast prototyping | MongoDB |
Comments
Post a Comment