No SQL
No SQL
1. Google BigTable
BigTable was developed by Google.
Used in:
Gmail
Google Maps
Web indexing
Characteristics
Distributed storage
High scalability
Fast data access
Category
BigTable belongs to:
Column-Based NoSQL Systems
Also called:
Wide Column Stores
Column Family Stores
2. Amazon DynamoDB
Amazon DynamoDB was developed by Amazon.
Category
Key-Value Data Stores
Also known as:
Key-Tuple Stores
Key-Object Stores
Features
Extremely fast lookups
Distributed architecture
Cloud integration
3. Cassandra
Apache Cassandra was originally developed by Facebook.
Now it is open source.
Features
Combines:
o Key-value concepts
o Column-based concepts
High scalability
Fault tolerance
Characteristics
Store data as documents
Usually use JSON-like structures
Flexible schemas
Advantages
Easy handling of semi-structured data
Suitable for web applications
Flexible data representation
Purpose
Designed to manage:
Networks
Relationships
Social connections
Applications
Social networks
Recommendation systems
Fraud detection
Characteristics
Combines features from:
Document databases
Graph databases
Key-value systems
Conclusion
NoSQL systems emerged because modern applications required:
Massive data storage
Distributed processing
Flexible data models
High scalability
Companies like Google, Amazon, and Facebook developed specialized NoSQL databases to
handle Internet-scale applications efficiently. Today, NoSQL databases are widely used in
cloud computing, social media, big data analytics, and real-time web applications.
Types of Scalability
1. Horizontal Scalability
Adding more nodes (servers) to the distributed system.
2. Vertical Scalability
Increasing storage or processing power of existing servers.
Example
If one server becomes overloaded:
Additional servers are added
Data is redistributed among servers
2. Availability, Replication, and Eventual
Consistency
Availability
Definition
Availability means the system continues functioning even when some nodes fail.
Replication
Definition
Replication means storing copies of data on multiple nodes.
Advantages of Replication
High Availability
If one node fails, another copy is available.
Improved Read Performance
Read requests can be processed from replicated nodes.
Fault Tolerance
Data loss is prevented.
Eventual Consistency
Traditional SQL systems require:
Serializable Consistency
where all copies are always identical immediately.
Many NoSQL systems instead use:
Eventual Consistency
meaning:
Updates propagate gradually.
All replicas eventually become consistent.
Limitation
Temporary inconsistencies may occur between replicas.
3. Replication Models
Two major replication models are used in NoSQL systems.
Working
Write Operations
Applied first to master.
Later propagated to slaves.
Read Operations
Can be configured in two ways:
Method Description
Reads from Master Only Latest data guaranteed
Reads from Slaves Faster reads but may return old data
Advantages
Simpler management
Better write control
Disadvantages
Master failure affects writes
Slaves may contain outdated data
Advantages
Higher availability
Better performance
No single point of failure
Disadvantages
Different nodes may temporarily store different values.
Conflicts occur when:
Multiple users update the same item simultaneously.
Reconciliation
Conflict resolution methods are required to:
Detect conflicts
Merge updates
Maintain consistency
4. Sharding of Files
Definition
Sharding means dividing a large file into smaller partitions called:
Shards
Also known as:
Horizontal Partitioning
Need for Sharding
Large applications may contain:
Millions of records
Thousands of concurrent users
Storing all records in one node causes:
Performance bottlenecks
Heavy load
Advantages of Sharding
Load Balancing
Data access workload is distributed.
Better Performance
Each node handles fewer records.
Scalability
Additional shards can be added easily.
5.1 Hashing
Definition
A hash function is applied to object keys.
h(K)h(K)h(K)
where:
K = object key
h(K) = storage location
Advantages
Very fast data retrieval
Uniform data distribution
Disadvantages
Range queries become difficult.
Advantages
Efficient for range queries.
Example:
Retrieve students with IDs between 100 and 500.
Disadvantages
Data may become unevenly distributed.
CRUD Operations
Operation Meaning
Create Insert data
Read Retrieve data
Update Modify data
Delete Remove data
SCRUD Operations
Some systems include:
Search (Find)
along with CRUD.
Limitation
Joins are often implemented manually in application programs.
3. Versioning
Some NoSQL systems store:
Advantages
Historical tracking
Recovery of old values
Better concurrency management
Example
A document may store:
Current version
Previous versions
Update timestamps
Disadvantages
Weak Consistency
Temporary inconsistencies may occur.
Limited Querying
Complex joins are difficult.
Complex Conflict Resolution
Especially in master-master replication.
Application-Level Constraints
Validation handled by programs.
Conclusion
NoSQL Databases systems are designed for:
Large-scale distributed applications
Flexible data storage
High availability
Horizontal scalability
They achieve high performance through:
Replication
Sharding
Eventual consistency
Schema-less design
These features make NoSQL systems suitable for modern web applications, cloud computing,
social media platforms, and big data environments.
Documents
usually using formats such as:
JSON
BSON
XML
Characteristics
Flexible schema
Semi-structured data storage
Easy handling of nested data
Fast retrieval using document IDs
Access Methods
Documents can be accessed using:
Document ID
Secondary indexes
Advantages
Flexible Structure
Different documents can have different fields.
Easy Data Representation
Suitable for real-world objects.
High Scalability
Supports distributed storage.
Applications
Content management systems
E-commerce websites
User profiles
Social media applications
Examples
MongoDB
CouchDB
Characteristics
Simple data model
Very fast access
Optimized for lookups
Working
The system retrieves data directly using the key.
Example:
Key Value
1001 Customer Record
A25 Product Information
Value May Contain
Record
Object
Document
Complex data structure
Advantages
Extremely Fast Retrieval
Ideal for real-time applications.
High Performance
Efficient read/write operations.
Scalability
Suitable for distributed systems.
Applications
Shopping carts
Session management
Caching systems
Real-time recommendations
Examples
Amazon DynamoDB
Redis
Column Families
instead of storing entire rows together.
Concept
Traditional relational databases store data row-wise.
Column-based systems store:
Related columns together.
This is a form of:
Vertical Partitioning
Characteristics
High compression efficiency
Fast column retrieval
Efficient analytics processing
Supports versioning
Versioning
These systems often maintain:
Multiple versions of data
Timestamps for each version
Advantages
Efficient for Big Data Analytics
Only required columns are read.
High Scalability
Supports distributed storage.
Faster Aggregation
Good for analytical queries.
Applications
Big data processing
Data warehousing
Real-time analytics
Examples
BigTable
Apache HBase
Apache Cassandra
Characteristics
Relationship-oriented storage
Efficient graph traversal
Path-based querying
Advantages
Efficient Relationship Handling
Excellent for connected data.
Fast Traversal
Quickly navigates relationships.
Flexible Data Modeling
Supports complex networks.
Applications
Social networks
Recommendation systems
Fraud detection
Network analysis
Examples
Neo4j
GraphBase
Advantages
Flexible architecture
Multiple data models
Supports diverse applications
Example
OrientDB
6. Object Databases
Definition
Object databases store data as:
Objects
Classes
Methods
based on object-oriented concepts.
Characteristics
Object identity
Encapsulation
Inheritance
Applications
CAD systems
Multimedia systems
Engineering applications
7. XML Databases
Definition
XML databases store data in:
XML Format
Characteristics
Hierarchical structure
Self-describing data
Flexible representation
Applications
Web services
Document management
Data exchange systems
Examples
Google Search
Microsoft Bing
Disadvantages
Lack of Standardization
Different systems use different models.
Learning Complexity
Each category has unique concepts.
Limited Cross-Compatibility
Migration between systems may be difficult.
Conclusion
NoSQL Databases are classified into multiple categories based on how they store and access
data. The four primary categories are:
Document-based systems
Key-value stores
Column-based systems
Graph-based systems
Additional categories such as hybrid, object-oriented, and XML databases further extend
NoSQL capabilities. These systems are widely used in big data, cloud computing, analytics,
social networking, and distributed web applications because of their scalability, flexibility,
and high performance.
Strong Consistency
Ensures:
Every user sees the latest data.
All replicas remain synchronized.
However:
High communication overhead
Reduced performance
Slower writes
Weak Consistency
Allows:
Temporary inconsistency between replicas.
Better performance and availability.
Many NoSQL systems prefer weak consistency.
CAP Properties
1. Consistency (C)
Definition
All nodes see the same data at the same time.
After an update:
Every replica reflects the same value.
Example
If a bank balance changes:
All users must immediately see the updated balance.
Consistency in CAP
Refers to:
Uniformity among replicated copies.
Consistency in ACID
Refers to:
Preservation of database integrity constraints.
2. Availability (A)
Definition
Every request receives a response.
The system:
Continues operating
Even if some nodes fail
Characteristics
Read/write requests are processed.
Users receive successful responses whenever possible.
Example
A social media site remains accessible even if some servers fail.
Network Partition
A partition occurs when:
Nodes cannot communicate with each other.
Example:
Network cable failure
Communication breakdown
Suitable For
Traditional centralized SQL systems.
Limitation
Some requests may be rejected.
Availability decreases during partitions.
Suitable For
Applications requiring accurate data:
Banking systems
Financial applications
Limitation
Temporary inconsistencies may occur.
Suitable For
Most NoSQL systems:
Social media
E-commerce
Web applications
Eventual Consistency
Many NoSQL systems use:
Eventual Consistency
instead of strong consistency.
Definition
Replicas may temporarily differ, but eventually all copies become consistent.
Characteristics
Faster performance
Better scalability
Higher availability
Example
A social media post may appear on some servers immediately and on others after a short
delay.
Examples
System CAP Preference
MongoDB AP / eventual consistency
Apache Cassandra AP
Apache HBase CP
Disadvantages
Temporary Inconsistency
Users may see different values.
Complex Design
Conflict resolution becomes difficult.
Reduced Transaction Guarantees
Strong ACID properties may not be fully supported.
Conclusion
CAP Theorem explains that a distributed replicated system cannot simultaneously achieve:
Consistency
Availability
Partition tolerance
Designers must choose the most suitable combination depending on application requirements.
Most NoSQL Databases prioritize:
Availability
Partition tolerance
and therefore use weaker consistency models such as eventual consistency to achieve high scalability
and performance in distributed environments.
Document Stores
Characteristics of Document-Based Systems
Flexible schema
Self-describing data
Semi-structured storage
Easy scalability
Fast retrieval
Unlike relational databases:
No fixed schema is required.
Documents in the same collection may have different structures.
Document Structure
Documents resemble:
Complex objects
XML documents
JSON objects
However:
No predefined schema is mandatory.
New attributes can be added dynamically.
Self-Describing Data
Each document contains:
Data values
Attribute names
Hence, the database can automatically identify:
Fields
Data types
Structure
JSON Format
A commonly used document format is:
JSON
(JavaScript Object Notation)
BSON Format
(Binary JSON)
BSON
Definition
BSON is:
A binary representation of JSON
More storage efficient
Supports additional data types
Collections in MongoDB
Documents are grouped into:
Collections
A collection is similar to a table in relational databases.
Creating Collections
MongoDB uses:
[Link]()
Example
[Link]("project",
{ capped : true, size : 1310720, max : 500 })
Explanation
Parameter Meaning
project Collection name
capped Fixed-size collection
size Maximum storage size
max Maximum number of documents
ObjectId in MongoDB
Every document contains a unique field:
_id
Characteristics
Automatically indexed
Unique for each document
Similar to primary key
ObjectId Generation
MongoDB can:
Automatically generate ObjectIds
OR
Accept user-defined ObjectIds
1. Denormalized Design
Embedded Subdocuments
Workers are stored directly inside the project document.
Example
{
"_id": "P1",
"Pname": "ProductX",
"Workers": [
{
"Ename": "John Smith",
"Hours": 32.5
}
]
}
Advantages
Faster retrieval
No joins needed
Good read performance
Disadvantages
Data redundancy
Update complexity
Example
{
"_id": "P1",
"WorkerIds": ["W1", "W2"]
}
Separate worker documents:
{
"_id": "W1",
"Ename": "John Smith"
}
Advantages
Reduced redundancy
Better modularity
Disadvantages
Additional lookups required
3. Normalized Design
Project and worker documents are stored separately.
Example
Project document:
{
"_id": "P1",
"Pname": "ProductX"
}
Worker document:
{
"_id": "W1",
"ProjectId": "P1"
}
Advantages
Reduced duplication
Better consistency
Disadvantages
More complex retrieval
Requires application-level joins
Example
[Link](
{
_id: "P1",
Pname: "ProductX"
})
1. Create Operation
Insert
[Link](document)
2. Read Operation
Find
[Link](condition)
Example
[Link]({Ename:"John Smith"})
3. Update Operation
Updates documents using:
[Link]()
with:
Selection condition
$set clause
Example
[Link](
{_id:"W1"},
{$set:{Hours:40}})
4. Delete Operation
MongoDB uses:
[Link](condition)
Example
[Link]({_id:"W1"})
Replication in MongoDB
MongoDB uses:
Replica Sets
to maintain multiple copies of data.
Primary Node
Stores main copy
Processes all writes
Secondary Nodes
Maintain replicated copies
Can process reads
Arbiter
Does not store data
Helps elect new primary
Replica Set Requirements
Minimum 3 participants
Total members should be odd
Example:
1 Primary
1 Secondary
1 Arbiter
Read Preference
Mode Advantage Limitation
Primary Latest data Lower read scalability
Secondary Faster reads Possible outdated data
Sharding in MongoDB
Definition
Sharding divides collections into:
Shards
Also called:
Horizontal Partitioning
Purpose of Sharding
Improve performance
Support large datasets
Enable horizontal scalability
Achieve load balancing
Shard Key
MongoDB partitions documents using:
Shard Key
Requirements of Shard Key
Must:
1. Exist in every document
2. Have an index
Partitioning Methods
MongoDB supports:
1. Range partitioning
2. Hash partitioning
1. Range Partitioning
Documents grouped by key ranges.
Example:
Range Shard
1–1000 Shard 1
1001–2000 Shard 2
Advantages
Efficient range queries
Disadvantages
Uneven data distribution
2. Hash Partitioning
A hash function is applied:
h(K)h(K)h(K)
where:
K = shard key
Advantages
Uniform distribution
Better load balancing
Disadvantages
Inefficient range queries
Query Router
MongoDB uses a:
Query Router
to:
Track shard locations
Route queries to correct shards
Replication vs Sharding
Feature Replication Sharding
Purpose Availability Scalability
Method Copy data Partition data
Benefit Fault tolerance Load balancing
Advantages of MongoDB
Flexible Schema
Supports dynamic documents.
Horizontal Scalability
Easy addition of nodes.
High Availability
Replica sets provide fault tolerance.
High Performance
Fast document retrieval.
Distributed Processing
Supports large-scale applications.
Disadvantages of MongoDB
Weak Consistency
Eventual consistency may occur.
Complex Distributed Management
Replication and sharding increase complexity.
Data Redundancy
Denormalized designs duplicate data.
Applications of MongoDB
Social media
Real-time analytics
E-commerce
Content management
Big data applications
Conclusion
MongoDB is a powerful document-based NoSQL Databases system that stores data as
flexible BSON documents. It supports:
Schema-less design
CRUD operations
Replication
Sharding
Horizontal scalability
Key-Value Stores
These systems focus on:
High performance
Scalability
Availability
Fast data access
Key
The key:
Uniquely identifies data
Is used for fast retrieval
Example:
StudentID
ProductID
UserID
Value
The value:
Contains actual data
May be structured or unstructured
Possible formats:
String
Array of bytes
JSON document
Object
Record
Main Characteristic
Every value must be associated with:
A unique key
Retrieval using the key must be:
Extremely fast
Features of Key-Value Stores
High Performance
Fast key-based access.
Horizontal Scalability
New nodes can be added easily.
High Availability
Replication ensures data availability.
Simplicity
Simple data model and operations.
Distributed Storage
Data stored across multiple nodes.
Query Language
Most key-value stores:
Do not use SQL
Provide APIs and operations instead
Common operations:
Get
Put
Delete
Table
A table:
Stores a collection of items
Does not require a fixed schema
Item
An item is:
A self-describing record/object
Similar to a row in relational databases
Attribute
An attribute:
Represents a field/value pair
Example:
{
"StudentID": 101,
"Name": "Anil",
"Department": "CSE"
}
JSON Support
DynamoDB allows:
JSON input format
The system converts JSON into:
Internal storage format
Characteristics
Fast lookup
Items not stored in order
Example
Attribute Role
ItemID Hash key
Timestamp Range key
Advantages
Supports multiple versions
Allows ordering
Enables secondary indexes
1. Put Operation
[Link](k, v)
Purpose
Inserts:
Key k
Value v
2. Get Operation
v = [Link](k)
Purpose
Retrieves:
Value associated with key k
3. Delete Operation
[Link](k)
Purpose
Deletes:
Item with key k
Storage Format
Internally:
Keys and values stored as arrays of bytes
Serializer Class
A serializer:
Converts user data into byte arrays
Converts byte arrays back into user format
Consistent Hashing
Project Voldemort uses:
Consistent Hashing
for:
Data distribution
Replication
Scalability
Hash Function
A hash function is applied:
h(k)h(k)h(k)
where:
k = key
Ring Structure
Consistent hashing visualizes:
Hash values
Nodes
on a circular ring.
Node Placement
Nodes are placed:
Pseudorandomly on the ring
Each node may appear:
Multiple times
depending on capacity.
Replication in Voldemort
Replication is achieved by:
Storing replicas on successive nodes clockwise.
Sharding in Voldemort
Different key-value pairs stored on different nodes.
This provides:
Vector Clocks
Each write operation receives:
A vector clock value
to track versions.
Read Repair
During reads:
Different replicas compared
Conflicts resolved
This technique is called:
Read Repair
Conflict Resolution
If system cannot automatically reconcile versions:
Multiple versions returned to application
Application resolves conflict
Redis
Redis is:
In-memory key-value store
Extremely fast
Features of Redis
Main Memory Caching
Stores data in RAM.
High Performance
Very low latency.
Replication
Supports master-slave replication.
Persistence
Backs up data to disk.
Apache Cassandra
Apache Cassandra:
Hybrid NoSQL system
Combines:
o Key-value features
o Column-based features
Originally developed by:
Facebook
Features of Cassandra
Distributed architecture
High scalability
High availability
Fault tolerance
Conclusion
NoSQL Databases key-value stores provide:
High performance
Scalability
Fast key-based access
Distributed storage
Systems such as Amazon DynamoDB, Project Voldemort, and Redis are widely used for
large-scale distributed applications where fast retrieval and availability are more important
than complex query processing.
Examples
Google Bigtable
Apache HBase
Apache Cassandra
Important Feature
Column-based systems use:
Multidimensional keys
Key consists of:
Table name
Row key
Column family
Column qualifier
Timestamp
Row Key
Must be lexicographically ordered
Used for fast retrieval
Column Families
Group related columns together
Defined during table creation
Cannot be changed later
Example:
create 'EMPLOYEE', 'Name', 'Address', 'Details'
Column Qualifiers
Defined dynamically during insertion
Makes data self-describing
Column
A column is:
ColumnFamily : ColumnQualifier
Example:
Name:Fname
Details:Job
Timestamp System
HBase uses:
January 1, 1970 UTC as zero time
Timestamp stored in:
Milliseconds
Cells
A cell stores:
Basic data item
Cell key contains:
Table
RowID
Column Family
Column Qualifier
Timestamp
Namespace
Namespace:
Collection of tables
Similar to:
Database in relational DBMS
Create Table
create 'EMPLOYEE', 'Name', 'Address', 'Details'
Insert Data
put 'EMPLOYEE', 'row1', 'Name:Fname', 'John'
Important Point
HBase provides:
Only low-level CRUD operations
Complex operations like:
Joins
must be handled by:
Application programs
24.5.3 HBase Storage and Distributed
Concepts
Regions
Tables divided into regions
Each region stores range of row keys
Stores
Each column family stored separately
Stored inside regions
Region Servers
Regions assigned to region servers
Region servers act as storage nodes
Master Server
Responsible for:
1. Monitoring region servers
2. Splitting tables into regions
3. Assigning regions
Zookeeper
Apache ZooKeeper used for:
Coordination
Synchronization
Replication
Node management
HDFS
Hadoop Distributed File System used for:
Distributed file storage
HBase Architecture
HBase built on:
HDFS
Zookeeper
Applications
Gmail
Big data analytics
Cloud computing
Distributed storage systems
Neo4j Overview
Neo4j is a popular graph database.
Open-source system.
Implemented in Java.
Used for applications involving connected data.
2. Labels
Labels identify node types.
Nodes with same label belong to same group.
Example
EMPLOYEE
DEPARTMENT
PROJECT
Multiple Labels
A node can have multiple labels.
Example:
PERSON:EMPLOYEE:MANAGER
3. Properties
Properties store data values.
Written inside { }.
Example
{Name:'John', Salary:'50000'}
4. Relationships
Relationships connect nodes.
Relationships are directed.
Example
(e1)-[:WorksFor]->(d1)
Meaning:
Employee works for department.
5. Relationship Types
Examples:
WorksFor
Manager
LocatedIn
WorksOn
6. Relationship Properties
Relationships can also store data.
Example
(e1)-[:WorksOn {Hours:'32.5'}]->(p1)
Here:
Hours is relationship property.
7. Paths
Path = traversal through graph.
Used in graph queries.
Example
Employee → WorksOn → Project
8. Optional Schema
Neo4j does not require schema.
Schema can be added optionally.
Supports:
Constraints
Indexes
9. Indexing
Neo4j creates unique internal node identifiers.
Indexes improve search speed.
Examples
Empid index for EMPLOYEE
Dno index for DEPARTMENT
Pno index for PROJECT
Creating Nodes
Example
CREATE (e1: EMPLOYEE {Empid:'1', Fname:'John'})
Creating Relationships
Example
CREATE (e1)-[:WorksFor]->(d1)
Example Queries
1. Find Department Locations
MATCH (d:DEPARTMENT {Dno:'5'})-[:LocatedIn]->(loc)
RETURN [Link], [Link]
4. Sorting Results
ORDER BY [Link]
5. Limiting Results
LIMIT 10
7. Updating Property
MATCH (e:EMPLOYEE {Empid:'2'})
SET [Link]='Engineer'
2. Graph Visualization
Neo4j can display data graphically.
Useful for:
o Query visualization
o Relationship analysis
3. Master-Slave Replication
One master node controls updates.
Slave nodes contain replicated data.
Advantages:
High availability
Fault tolerance
4. Caching
Main memory cache improves speed.
5. Logical Logs
Logs used for recovery after failures.
Applications of Neo4j
Social networks
Recommendation systems
Fraud detection
Network analysis
Knowledge graphs