AIDM7450 Chap.6 Relational Data and MongoDB CRUD
Relational Data and MongoDB CRUD
Choose a data model from the workload
A database management system centralises access, integrity, security and recovery. This chapter reviews transactions and the ACID properties before comparing relational tables, primary and foreign keys with document collections, documents and fields. MongoDB's JSON-like model supports flexible aggregates but uses different query and join assumptions.
CRUD is treated as a result-checked cycle: inserted identifiers, returned documents, matched and modified counts, and deleted counts are evidence that the intended operation reached the intended record.
Relational and document models can represent the same digital-media story while making different operations easy to express.
Tables expose relationships through keys and joins; a document can keep a frequently retrieved aggregate together through embedded fields or references. The decision follows workload and integrity needs rather than a product slogan.
Connection lifecycle is part of correctness as well: create the client from protected configuration, connect, await operations, handle errors and close the resource even when an operation fails.
What this chapter covers
- 01
DBMS access, integrity and recovery
- 02
Transactions and ACID properties
- 03
Relational tables and key relationships
- 04
SQL definition and manipulation roles
- 05
NoSQL database families
- 06
JSON-like document storage
- 07
MongoDB insert, find, update and delete results
Worked example · free
Model a digital story collection
- 3Describe a relational story and media relationship.
- 3Describe an embedded document aggregate.
- 3Recommend from the stated access pattern and trade-off.
Key terms
- DBMS
- Software that manages databases and provides controlled client access to stored data.
- Transaction
- A unit of work that completes as a whole or leaves the system unchanged.
- Primary Key
- One or more attributes that uniquely identify a record in a table.
- Foreign Key
- Attributes whose values reference the primary key of another table.
- Document Database
- A database model that stores data as self-contained documents with named fields.
- CRUD
- The create, read, update and delete operations used to manage stored data.
Relational Data and MongoDB CRUD FAQ
What does atomicity protect?
Atomicity protects a multi-step transaction from being left half complete. Either all effects occur or none do. Consistency, isolation and durability protect different contracts, so naming ACID without attaching each property to a failure mode does not explain the transaction.
Does JSON make something a document database?
No. JSON is a text representation used for data exchange. A document database adds persistence, indexing, querying, access control and operational behaviour. Applications may exchange JSON without storing it, and document databases may use JSON-like structures through a driver.
Why inspect matchedCount and modifiedCount separately?
A matched document proves the filter identified a record. Zero modification may mean the requested values were already present or the update did not target the intended field. No match means the filter failed. Read the postcondition before labelling either case successful or failed.
Exam move
Take one application feature and sketch both a relational and document representation. Mark identity, relationships, the usual read unit and one integrity rule. Then perform one create, read, update and delete operation with neutral test data, recording the result signal and postcondition. Treat the method call as an attempt and the returned counts or document as evidence.
Attach each ACID property to a concrete failure: partial completion for atomicity, invalid state for consistency, interference between concurrent work for isolation, and lost committed work for durability. Translate table, row and column into collection, document and field only as orientation, then list one difference that prevents the mapping from becoming an equivalence claim.
For the workload comparison, write the most frequent read and update before choosing embedded or referenced data. Use a unique neutral identifier in each CRUD filter and predict the returned signal. After insertion, record the identifier; after reading, handle no result; after updating, distinguish matched from modified counts; after deletion, verify deleted count and the absent postcondition.
Close the client in a final path and repeat one operation with a forced error to prove resource cleanup does not depend on success. Keep filters narrow throughout the exercise and inspect the intended record before destructive work, so a successful method return cannot conceal an operation against the wrong document.
Working through Relational Data and MongoDB CRUD in AIDM7450? Sia is AskSia’s AI Computer Science tutor — ask any AIDM7450 Relational Data and MongoDB CRUD question and get a clear, step-by-step explanation grounded in how AIDM7450 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.