No SQL lab manual
No SQL lab manual
CERTIFICATE
Enrollment No.
completed his/her term work in Course of “Introduction to NoSQL” with subject code
Practical-1
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.
Page | 5
Column-Family Stores: Column-family stores organize data into columns rather than rows,
making them suitable for handling large-scale, distributed data sets. These databases are
optimized for read-heavy workloads and excel in scenarios requiring efficient storage and
retrieval of large volumes 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.
Practical-2
Practical-3
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();
P a g e | 11
OUTPUT:-
OUTPUT:-
P a g e | 12
Practical-4
Aim:- Introduction and Setup of Cassandra.
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.
Install Cassandra on Windows:
Once the installer package is downloaded, double-click it to start the installation process.
Follow the on-screen instructions in the setup wizard. You can choose the installation
directory and other configuration options.
After installation, navigate to the Cassandra installation directory (usually located at
C:\Program Files\Apache Cassandra) and run the cassandra.bat file to start the Cassandra
server.
Practical-5
Aim:- Data Modeling and Simple Queries with Cassandra.
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:-
P a g e | 15
Creating a Table:
Define a table with a suitable primary key based on your data model and query requirements
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:-
P a g e | 16
Practical-6
4. Knowledge Graphs: Neo4j powers knowledge graphs for organizing and connecting diverse
data sources, enabling semantic search and data discovery.
Getting Started with Neo4j:
1. Download and Install Neo4j: Visit the official Neo4j website (https://neo4j.com/) to download
the Neo4j Community Edition or Enterprise Edition based on your requirements and
platform.
2. Start Neo4j Server: After installation, start the Neo4j server, which provides a web-based
interface (Neo4j Browser) for interacting with the database and running Cypher queries.
3. Explore Graph Data: Use Neo4j Browser to create nodes, relationships, and properties,
and perform queries using the Cypher query language to explore your graph data.
4. Develop Applications: Integrate Neo4j into your applications using Neo4j's drivers and
libraries available for various programming languages, such as Java, Python, JavaScript,
and more.
P a g e | 18
Practical-7
Aim:- Basic CRUD Operations with Neo4j Graph Databases
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.
● Delete a node