Unit 3: NoSQL and Big Data
Database Management Systems-II notes · PTU syllabus (UGCC2523)
On this page
Unit summary
Relational databases are not the best fit for every workload. NoSQL databases handle huge, fast-changing and unstructured data across many servers. This unit covers NoSQL data models, the CAP theorem, BASE vs ACID, CRUD in document databases, and an overview of Hadoop, MongoDB and Cassandra.
After this unit you can
- Explain why NoSQL emerged and its four data models
- State the CAP theorem and compare BASE with ACID
- Perform CRUD operations in MongoDB using operators
- Describe Hadoop, MongoDB and Cassandra
PTU syllabus topics
- Introduction to NoSQL
- document/key-value/column-family/graph data models
- features of NoSQL document databases
- CAP theorem
- BASE vs ACID
- CRUD operations
- overview of Hadoop/MongoDB/Cassandra
- MongoDB operator implementation
Structure
Tables with fixed schema
Documents, key-value, column, graph
Scaling
Mostly vertical
Horizontal across servers
Consistency
ACID
Often BASE (eventual consistency)
Example
MySQL, PostgreSQL
MongoDB, Cassandra
Topic 1
Introduction to NoSQL
NoSQL ("not only SQL") databases are non-relational databases designed for scale-out across many servers, flexible schemas and high-speed big-data workloads (social media, IoT, real-time analytics).
Document
JSON-like documents
MongoDB, CouchDB
Key-value
Key → value pairs
Redis, DynamoDB
Column-family
Rows with flexible column groups
Cassandra, HBase
Graph
Nodes and edges
Neo4j
Topic 2
CAP theorem and BASE
The CAP theorem says a distributed database can guarantee only two of: Consistency (every read sees the latest write), Availability (every request gets a response) and Partition tolerance (works despite network splits). Since partitions happen, systems choose between CP and AP.
Full form
Atomicity, Consistency, Isolation, Durability
Basically Available, Soft state, Eventually consistent
Consistency
Strong, immediate
Eventual
Focus
Correctness
Availability and scale
Example
Banking
Social media feeds
Topic 3
CRUD in MongoDB
javascriptdb.students.insertOne({ name: "Ana", course: "BCA", marks: 82 })
db.students.insertMany([{ name: "Ravi", marks: 74 }, { name: "Sara", marks: 91 }])
db.students.find({ marks: { $gt: 80 } }, { name: 1, _id: 0 }).sort({ marks: -1 })
db.students.updateOne({ name: "Ana" }, { $set: { marks: 85 } })
db.students.deleteOne({ name: "Ravi" })Operators: comparison ($eq, $gt, $lt, $in), logical ($and, $or, $not), update ($set, $inc, $push).
Topic 4
Hadoop, MongoDB and Cassandra
- Hadoop: a framework for storing and processing big data across clusters: HDFS (distributed file system), MapReduce (batch processing) and YARN (resource management).
- MongoDB: a document database with flexible JSON (BSON) documents, rich queries, indexing and sharding.
- Cassandra: a column-family database with no single point of failure, linear scalability and very high write throughput (AP in CAP terms).
Key terms
- NoSQL
- Non-relational databases built for scale and flexibility
- CAP theorem
- Only two of consistency, availability and partition tolerance at once
- Eventual consistency
- Replicas become consistent over time
- Document database
- Stores data as JSON-like documents
- HDFS
- Hadoop Distributed File System
Quick revision
- Four models: document, key-value, column-family, graph.
- CAP: pick two; partition tolerance is a must in distributed systems.
- ACID strong consistency; BASE eventual consistency.
- MongoDB: insertOne, find, updateOne + $set, deleteOne.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.What is NoSQL?
- Q2.Name the four NoSQL data models with one example each.
- Q3.State the CAP theorem.
- Q4.Differentiate between ACID and BASE.
- Q5.Write a MongoDB query to find students with marks above 75.
Long-answer questions
- Q1.Explain the NoSQL data models with examples.
- Q2.Explain the CAP theorem and compare ACID and BASE.
- Q3.Explain CRUD operations in MongoDB with queries and operators.
- Q4.Give an overview of Hadoop, MongoDB and Cassandra.
Stuck on this unit?
Message SBS on WhatsApp for help with Database Management Systems-II, or to ask about studying BCA at Synetic.
