NoSQL Overview
NoSQL (Not Only SQL) is a class of database systems that complement traditional relational databases.
Core Advantages
- Performance advantage: Achieves high throughput through distributed architecture
- Flexible data models: Document, key-value, column-family, graph databases
- Horizontal scaling capability
Four Major Families
-
Column Storage - HBase
- Designed based on Google Bigtable paper
- Suitable for massive structured data storage
- Typical applications: Financial transaction records, telecom call data
-
Key-Value Storage - Redis
- In-memory database with persistence support
- Typical applications: Session cache, ranking systems
- Features: Ultra-high performance (100k+ QPS)
-
Graph Storage - Neo4j
- Native graph database
- Typical applications: Social networks, recommendation systems, fraud detection
-
Document Storage - MongoDB
- BSON format storage
- Typical applications: Content management systems, product catalogs
MongoDB Introduction
MongoDB is an open-source NoSQL database using document data model.
Notable Features
- Document storage structure: Uses BSON format to store data
- Powerful query capabilities: Supports rich query expressions and indexes
- Distributed architecture: Natively supports sharding and replica sets
Architecture
- Storage engine: WiredTiger (default), In-Memory
- Query processing layer: Supports CRUD, aggregation pipeline, text search
- Sharding and replication layer: Replica sets, sharded clusters
- Security system: SCRAM authentication, RBAC, transport encryption
Comparison with Traditional Relational Databases
| Feature | MongoDB | Relational Database |
|---|---|---|
| Data Model | Document model, schema-less | Table structure, requires predefined schema |
| Scalability | Easy horizontal scaling | Primarily vertical scaling |
| Transaction Support | 4.0+ supports multi-document ACID | Full ACID transactions |
| Join Operations | Achieved through embedded documents | Achieved through JOIN |
Use Cases
More Suitable for MongoDB:
- Rapid iterative development
- Semi-structured or unstructured data
- Requires high scalability
- Geospatial data processing
More Suitable for Relational Database:
- Requires complex transaction processing
- Stable data structure
- Requires complex JOIN operations