import json
content = “””
Apa Itu NoSQL Database?
NoSQL (Not Only SQL) adalah kategori database yang tidak menggunakan model relasional tradisional. NoSQL dirancang untuk data terdistribusi, skala besar, dan skema fleksibel.
Jenis-Jenis NoSQL Database
- Document Store – MongoDB, CouchDB (JSON documents)
- Key-Value Store – Redis, DynamoDB, Memcached
- Column-Family – Cassandra, HBase
- Graph Database – Neo4j, Amazon Neptune
- Time-Series – InfluxDB, TimescaleDB
- Search Engine – Elasticsearch, Solr
SQL vs NoSQL
| Aspek | SQL | NoSQL |
|---|---|---|
| Schema | Fixed schema | Flexible schema |
| Scalability | Vertical (scale up) | Horizontal (scale out) |
| Consistency | ACID (strong) | BASE (eventual) |
| Query | SQL language | Various (JSON, CQL, Cypher) |
| Use Case | Complex queries, transactions | Big data, real-time, flexible |
| Examples | MySQL, PostgreSQL, Oracle | MongoDB, Redis, Cassandra, Neo4j |
Roadmap Belajar NoSQL
Level 1: Beginner
- MongoDB Basics – Documents, collections, CRUD operations
- Redis Basics – Strings, lists, sets, hashes, sorted sets
- JSON – Data format untuk document stores
- Query Language – MongoDB query syntax
- Indexing – Basic indexes
Level 2: Intermediate
- MongoDB Aggregation – Pipeline, match, group, project
- Redis Advanced – Pub/Sub, streams, Lua scripting
- Data Modeling – Embedding vs referencing
- Replication – Replica sets, sharding
- ODM/ORM – Mongoose (Node.js), MongoEngine (Python)
Level 3: Advanced
- Cassandra – Column-family, CQL, partitioning
- Neo4j – Graph queries, Cypher, graph algorithms
- Elasticsearch – Full-text search, aggregations
- Multi-model – ArangoDB, CosmosDB
Level 4: Expert
- Architecture – Polyglot persistence, CQRS
- Performance – Sharding, partitioning, caching strategies
- Consistency – CAP theorem, eventual consistency
- Migration – SQL to NoSQL migration strategies
Contoh Kode NoSQL
MongoDB
// Insert
db.users.insertOne({
nama: "Budi",
email: "budi@mail.com",
umur: 25,
hobi: ["Coding", "Gaming"],
alamat: { kota: "Jakarta", provinsi: "DKI" }
})
// Find
db.users.find({ umur: { $gte: 20 } })
db.users.find({ hobi: "Coding" })
db.users.findOne({ email: "budi@mail.com" })
// Update
db.users.updateOne(
{ nama: "Budi" },
{ $set: { umur: 26 }, $push: { hobi: "Reading" } }
)
// Aggregation
db.orders.aggregate([
{ $match: { status: "paid" } },
{ $group: { _id: "$user_id", total: { $sum: "$amount" } } },
{ $sort: { total: -1 } },
{ $limit: 10 }
])
Redis
# Strings
SET user:1:name "Budi"
GET user:1:name
INCR counter
EXPIRE user:1:name 3600
# Lists
LPUSH tasks "task1"
RPUSH tasks "task2"
LPOP tasks
LRANGE tasks 0 -1
# Sets
SADD tags "php" "javascript" "python"
SMEMBERS tags
SISMEMBER tags "php"
# Hashes
HSET user:1 nama "Budi" email "budi@mail.com" umur 25
HGET user:1 nama
HGETALL user:1
# Sorted Sets
ZADD leaderboard 100 "player1" 200 "player2"
ZREVRANGE leaderboard 0 2 WITHSCORES




