NO SQL
NO SQL
Introduction:
In today's data-driven world, the need for efficient and scalable data storage solutions
has led to the rise of NoSQL (Not Only SQL) databases. Unlike traditional relational
databases, NoSQL databases offer a flexible and schema-less approach to data
management, making them well-suited for handling large volumes of unstructured or
semi-structured data. This practical manual aims to explore the different types of
NoSQL databases, their characteristics, use cases, and best practices for
implementation.
Key-Value Stores: Key-value stores are among the simplest types of NoSQL
databases, where data is stored as a collection of key-value pairs. These databases
offer fast and efficient retrieval of data based on unique keys but typically lack
complex querying capabilities. Key-value stores are commonly used for caching,
session management, and real-time analytics. Examples of key-value stores include
Redis, DynamoDB (Amazon Web Services), and Riak.
Column-FamilyStores:Column-family stores organizedata into columns ratherthan rows,
makingthem suitablefor handlinglarge-scale,distributeddata sets. These databases are
optimized for read-heavy workloads and excel in scenarios requiringefficient storageand
retrievalof largevolumes of data with varying attributes.
Column-family stores are commonly used in data warehousing, analytics,and time-
series data storage.Notable examples of column-family databases include Apache
Cassandra, HBase (Hadoop Database), and ScyllaDB.
MongoDB supports CRUD operations, which stands for Create, Read, Update, and Delete. These operations
are fundamental for interacting with data in MongoDB. Below, I'll provide examples of each CRUD
operation using MongoDB's shell.
db.users.find();
OUTPUT:-
OUTPUT:-
Practical-4
Download Cassandra:
Start by visiting the official Apache Cassandra website at https://cassandra.apache.org/ and
navigate to the Downloads section. Choose the appropriate version of Cassandra based on your
operating system (Windows, macOS, or Linux) and download the installer package or tarball.
Cassandra replicates data across multiple nodes in a cluster to ensure high availability and fault
tolerance.Replication strategies (e.g., SimpleStrategy, NetworkTopologyStrategy) define how data is
distributed across nodes and data centers.
Primary Key Design:
The primary key consists of a partition key (mandatory) and optional clustering columns.
The partition key determines data distribution across nodes, while clustering columns define data
sorting within a partition.
Denormalization and Query-Driven Design:
Denormalization is common in Cassandra to optimize read performance by reducing the need for
joins.Design tables based on specific query patterns to minimize data duplication and ensure efficient
queries.
Simple Queries with Cassandra:
Creating a Keyspace: Start by creating a keyspace, which acts as a container for tables in Cassandra.
OUTPUT:-
Creating a Table:
Define a table with a suitable primary key based on your data model and query requirements
CREATE TABLE IF NOT EXISTS my_keyspace.users
( user_id UUID PRIMARY KEY, name TEXT, email
TEXT,
age INT
);
OUTPUT:-
Inserting Data: Insert data into the table using the INSERT INTO statement.
INSERT INTO my_keyspace.users (user_id, name, email, age)
VALUES (uuid(), 'John Doe', '[email protected]', 30);
OUTPUT:-
Practical-6
Neo4j provides a powerful query language called Cypher for performing CRUD (Create,
Read, Update, Delete) operations on graph data. Below are examples of basic CRUD
operations using Cypher in Neo4j.