Quiz 2

NoSQL Databases

319 words
2 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# NoSQL Databases ## 🎯 Learning Objectives - Compare SQL and NoSQL databases - Understand the CAP theorem and its implications - Choose the right NoSQL database for a use case - Design documents for MongoDB ## 📖 Core Content ### 5.1 SQL vs NoSQL Aspect SQL (Relational) NoSQL Data model Tables, rows, columns Docume...

NoSQL Databases

🎯 Learning Objectives

  • Compare SQL and NoSQL databases
  • Understand the CAP theorem and its implications
  • Choose the right NoSQL database for a use case
  • Design documents for MongoDB

📖 Core Content

5.1 SQL vs NoSQL

AspectSQL (Relational)NoSQL
Data modelTables, rows, columnsDocument, key-value, graph, column
SchemaFixed (requires migration)Flexible (schema-on-read)
ScalabilityVertical (scale up)Horizontal (scale out)
ACIDYesOften BASE (eventual consistency)
JoinsYesNo (denormalized)
Best forComplex queries, consistencyHigh volume, flexible schema

5.2 CAP Theorem

A distributed database can only guarantee two of three:
  • Consistency: Every read gets the most recent write
  • Availability: Every request gets a response (even if outdated)
  • Partition tolerance: System works despite network failures (Diagram)

5.3 NoSQL Types

TypeExampleUse CaseData Model
DocumentMongoDBContent management, catalogsJSON documents
Key-ValueRedisCaching, session storeKey → value pairs
Column-FamilyCassandraTime-series, IoTRow key → columns
GraphNeo4jSocial networks, recommendationsNodes and edges

📝 Practice Questions

Q1: When would you choose MongoDB over PostgreSQL?
Choose MongoDB when: (1) data has varying schemas (product catalog where different products have different attributes), (2) you need fast prototyping without migrations, (3) you're scaling horizontally across many servers. Choose PostgreSQL when: (1) data is highly relational, (2) you need ACID transactions, (3) complex queries with JOINs are common. Q2: What does "eventual consistency" mean?
In distributed systems, updates propagate asynchronously. After a write, reads may see old data for a brief period, but all replicas will eventually converge to the same value. Typical in AP systems (Cassandra, DNS). Tradeoff: higher availability and partition tolerance at the cost of temporary inconsistency. Q3: When is a graph database the right choice?
When the relationships between data are as important as the data itself. Examples: social network (users + friendships), recommendation engine (customers + products + purchases), fraud detection (accounts + transactions). Graph DBs excel at traversal queries like "find all friends of friends within 3 degrees." Join Discord PreviousBig Data: Hadoop & SparkNextData Governance
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.