AD Practical 2
What is a NoSQL Database?
NoSQL (Not Only SQL) databases are a type of database management system
designed to handle large-scale data storage and retrieval. Unlike traditional relational
databases (RDBMS), NoSQL databases do not use structured tables with fixed
schemas. Instead, they are optimized for unstructured, semi-structured, and distributed
data storage.
Key Characteristics of NoSQL Databases
Schema-less – No fixed schema, allowing for flexible and dynamic data
storage.
Scalability – Horizontally scalable by adding more servers instead of
upgrading a single machine.
High Performance – Optimized for fast read/write operations, making them
suitable for large datasets.
Data Model Flexibility – Supports multiple data models such as key-value,
document, column-family, and graph databases.
ACID vs. BASE – NoSQL databases generally follow BASE
(Basically Available, Soft state, Eventually consistent) rather than strict
ACID
compliance.
Distributed Storage – Data is stored across multiple nodes for high
availability and fault tolerance.
Auto-Sharding – Automatically distributes data across multiple
servers without manual intervention.
Replication – Supports data replication to enhance availability and reduce
downtime.
Eventual Consistency – Ensures data is eventually consistent across
distributed nodes, even if updates take time to propagate.
Support for Big Data – Designed to handle large-scale, high-speed
data processing and storage.
Why Use NoSQL?
Handling Unstructured Data – Best for applications dealing with
unstructured or semi-structured data like JSON, XML, and multimedia.
Big Data Applications – Efficiently processes and stores large volumes of
data in real time.
High Availability – Ensures data accessibility even in cases of system
failure through replication and distribution.
Scalability – Supports horizontal scaling, making it easy to manage
increasing workloads.
Cloud-Based Applications – Ideal for cloud storage due to its
distributed architecture.
Real-Time Analytics – Supports fast querying and analytics, which is
essential for real-time applications.
Flexible Schema Evolution – Allows dynamic changes to data
structures without downtime.
Reduced Cost – Often open-source and does not require expensive licensing
like relational databases.
Easier Development – Faster application development since it does not
require complex schema design.
Internet of Things (IoT) – Supports high-speed data collection from
IoT devices and real-time processing.
Types of NoSQL Databases
NoSQL databases are classified into four main categories based on how they store and
retrieve data:
1. Document Databases
Store data in JSON, BSON, or XML format.
Schema-less, flexible, and easy to scale.
Examples: MongoDB, CouchDB, Cloudant.
Use Cases: Content management systems, catalogs, user profiles.
2. Key-Value Stores
Store data as key-value pairs for fast retrieval.
Optimized for caching and real-time processing.
Examples: Redis, Memcached, Amazon DynamoDB.
Use Cases: Caching, session management, leaderboards.
3. Column-Family Stores
Store data in columns instead of rows, enabling fast analytics.
Efficient for distributed computing and large-scale data handling.
Examples: Apache Cassandra, HBase, Google Bigtable.
Use Cases: IoT applications, time-series data, big data analytics.
4. Graph Databases
Store data as nodes and edges, making them ideal for relationship-based
queries.
Best suited for analyzing connected data.
Examples: Neo4j, Amazon Neptune, ArangoDB.
Use Cases: Fraud detection, recommendation engines, social networks.
Advantages of NoSQL
High Scalability – Uses sharding for horizontal scaling.
Flexibility – Adapts to changing data structures.
High Availability – Data replication ensures fault tolerance.
Cost-Effective – Less complex, reducing hardware and software costs.
Agility – Ideal for modern, agile application development.
Disadvantages of NoSQL
Lack of Standardization – Multiple types with varying implementations.
Limited ACID Compliance – Prioritizes speed over strict consistency.
Narrow Focus – Less suited for transactional applications.
Complex Management – Requires expertise in distributed systems.
Backup Challenges – Some NoSQL databases, like MongoDB, lack
proper backup mechanisms.
1. Document Databases (Example: MongoDB)
Stores data in JSON-like format (BSON).
2. Key-Value Stores (Example: Redis)
Stores data as key-value pairs.
3. Column-Family Stores (Example: Apache Cassandra)
Stores data in rows and columns but groups related columns into "column
families."
4. Graph Databases (Example: Neo4j)
Stores data as nodes and relationships.