Unit 3 of 4 · BCA Sem 4

Unit 3: NoSQL and Big Data

Database Management Systems-II notes · PTU syllabus (UGCC2523)

3 min read4 topics9 exam questions
On this page
  1. Unit summary
  2. Introduction to NoSQL
  3. CAP theorem and BASE
  4. CRUD in MongoDB
  5. Hadoop, MongoDB and Cassandra
  6. Key terms
  7. Quick revision
  8. Important questions

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
ComparisonSQL vs NoSQL
SQL
NoSQL

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

1

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).

ComparisonNoSQL data models
Stores data as
Example

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

2

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.

ComparisonACID vs BASE
ACID (relational)
BASE (many NoSQL)

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

3

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).

4

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

  1. Q1.What is NoSQL?
  2. Q2.Name the four NoSQL data models with one example each.
  3. Q3.State the CAP theorem.
  4. Q4.Differentiate between ACID and BASE.
  5. Q5.Write a MongoDB query to find students with marks above 75.

Long-answer questions

  1. Q1.Explain the NoSQL data models with examples.
  2. Q2.Explain the CAP theorem and compare ACID and BASE.
  3. Q3.Explain CRUD operations in MongoDB with queries and operators.
  4. 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.

WhatsApp us