Learning Journal Week 7- CST363
MongoDB and MySQL are both widely used databases, but they serve different purposes depending on the type of data and the goals of the application. MySQL is a relational database that organizes information into tables made up of rows and columns. It uses structured query language (SQL) to define schemas, create relationships, and perform queries such as SELECT, JOIN, and UPDATE. MongoDB, on the other hand, is a NoSQL database that stores data as flexible JSON-like documents inside collections. Each document can have its own structure, which makes MongoDB more adaptable to unstructured or frequently changing data.
Both systems share some important similarities. They are open source, support indexing for faster data access, and allow basic operations like inserting, reading, updating, and deleting data. Both also offer replication for high availability and tools for monitoring and backups. In our SQL labs, we practiced commands such as CREATE TABLE, INSERT INTO, and SELECT * FROM to organize data into structured tables. We also used normalization to reduce redundancy and foreign keys to maintain relationships between entities, such as in Lab 18 and Lab 19 where we designed and implemented a prescription database with tables like doctor, patient, and pharmacy. In contrast, the MongoDB lab focused on using commands like db.patients.insert() and db.patients.find() to manage collections and documents without worrying about predefined schemas.
The key difference between the two lies in structure and flexibility. MySQL requires a defined schema before data is added, which ensures consistency and integrity. It is best suited for systems that require strong relationships and transactions, such as financial or inventory applications. MongoDB does not require a schema, allowing you to easily add new fields or change data formats as the application evolves. It scales horizontally across multiple servers, making it ideal for large, rapidly growing datasets like user activity logs or real-time analytics.
In summary, MySQL works best for structured data and applications that demand accuracy and consistency, while MongoDB is ideal for projects that need flexibility and scalability. The labs made this difference clear: MySQL enforces structure and relationships, while MongoDB gives developers freedom to model data as needed for modern, fast-changing applications.
Comments
Post a Comment