0% found this document useful (0 votes)
11 views9 pages

Introduction to NoSQL Databases

NoSQL, which stands for 'Not Only SQL', is a non-relational database system designed for managing large volumes of unstructured and semi-structured data, commonly used in applications like social media and real-time analytics. It offers benefits such as flexibility, high scalability, and faster performance, with various types including key-value stores, document-oriented databases, column-oriented databases, and graph databases. MongoDB is a popular open-source NoSQL database that stores data in a schema-less format, and the document also discusses database backup and recovery concepts essential for data safety and integrity.

Uploaded by

amrutaoffical5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views9 pages

Introduction to NoSQL Databases

NoSQL, which stands for 'Not Only SQL', is a non-relational database system designed for managing large volumes of unstructured and semi-structured data, commonly used in applications like social media and real-time analytics. It offers benefits such as flexibility, high scalability, and faster performance, with various types including key-value stores, document-oriented databases, column-oriented databases, and graph databases. MongoDB is a popular open-source NoSQL database that stores data in a schema-less format, and the document also discusses database backup and recovery concepts essential for data safety and integrity.

Uploaded by

amrutaoffical5
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

6.

1 Introduction to NoSQL
• NoSQL stands for “Not Only SQL”.
• It is a non-relational database system designed to store and
manage large volumes of unstructured, semi-structured, or
rapidly changing data.
• They are widely used in applications like social media, IoT,
real-time analytics, cloud computing, and big data systems.

Difference between SQL and NoSQL:-


Benefits of NoSQL
1. Flexibility
2. High Scalability
3. Faster Performance
4. Big Data Handling
5. Schema-less
6. Cloud & Distributed Support .

Types of NoSQL Databases


1. Key-Value Stores
o Data stored as key-value pairs.
o Example: Redis, DynamoDB.
2. Document-Oriented Databases
o Stores data as documents (JSON, BSON, XML).
o Example: MongoDB, CouchDB.
3. Column-Oriented Databases
o Stores data in columns instead of rows.
o Best for analytical queries and big data.
o Example: Cassandra, HBase.
4. Graph Databases
o Stores data in nodes and edges for relationship-heavy
data.
o Example: Neo4j, OrientDB.
6.2 MongoGODB :-
1) MongoDB is an open-source NoSQL database.
2) It stores data in documents instead of rows and columns like
SQL.
3) MongoDB is schema-less, which means the structure of data
is flexible.
4) Data is stored in collections (similar to tables) and documents
(similar to rows, but in JSON format).

1. Installation of MongoDB
• Download MongoDB Community Server.
• Install and set path in environment variables.
• Create data\db folder for storage.
• Run server using mongod.
• Run client shell using mongo.

2. Querying with MongoDB


• Insert:
• [Link]({name:"Shradha", age:20})
• Find:
• [Link]()
• [Link]({age:20})
• Update:
• [Link]({name:"Shradha"}, {$set:{age:21}})
• Delete:
[Link]({name:"Shradha"})

6.3. Database Backup


A database backup is a copy of the data that can be used to
restore the database in case of failures.
Backup ensures data safety, reliability, and availability.

Types of Failures in Database


1. Transaction Failure – Error in transaction (e.g., invalid input,
deadlock).
2. System Failure – Crash of hardware/software, power failure.
3. Media Failure – Disk crash, data corruption, storage damage.
4. Application Failure – Error in application program affecting
database.
5. Natural Disaster Failure – Fire, flood, earthquake, etc.

Causes of Failure
• Hardware malfunction (disk crash, memory failure).
• Software bugs or system crash.
• Power outage or sudden shutdown.
• Human errors (accidental deletion, wrong command).
• Virus attack or malicious activity.
• Natural disasters.

What is Database Backup?


• A database backup is a copy of the database that is taken and
stored separately to protect data against loss, damage, or
failure.
• It ensures that in case of system crash, hardware failure,
human error, or natural disaster, the database can be restored
to its previous consistent state.
• Backups are an essential part of database recovery and
security.

Types of Database Backup

Physical Backup
• Backup of the physical files (data files, log files, control files).
• Used for disaster recovery.
• Faster but requires more storage.

Logical Backup
• Backup of logical data like tables, views, procedures, etc.
• Usually exported using tools (e.g., mysqldump).
• More flexible but slower compared to physical backup.
6.4 Database Recovery-Recovery Concepts:-

1. What is Database Recovery?


Database Recovery is the process of restoring a database to a
correct state after a failure, such as:
• System crash
• Transaction failure
• Media failure (e.g., disk failure)
• Power outage
• Human errors (e.g., accidental deletion)
It ensures that the ACID properties (Atomicity, Consistency,
Isolation, Durability) are maintained even in failure situations.

2. Recovery Concepts in RDBMS


To understand recovery, you need to understand these key
concepts:

Concept Description

A logical unit of work (e.g., money transfer)


Transaction
that must be atomic.

A file that records all changes made by


Log File
transactions (write-ahead logging).

A point in time where the database ensures


Checkpoint
that all data is written to disk.
Concept Description

Finalizing a transaction (changes are


Commit
permanent).

Undoing a transaction (incomplete or failed


Rollback
changes are removed).

Reapplying the changes from committed


Redo
transactions during recovery.

3. Recovery Techniques
RDBMSs typically use two core techniques for recovery:

A. Roll Forward (Redo)

➤ Definition:
Roll forward means reapplying the changes of committed
transactions to the database using the log file after a crash.

➤ Purpose:
To ensure that all committed transactions are reflected in the
database even if they were not physically written to disk at the
time of crash.

➤ When is it used?
• After system crash or media failure
• During media recovery

➤ Process:
1. Restore the most recent backup
2. Use the log file (redo log) to reapply the changes made by
committed transactions
3. Update the database accordingly

➤ Example:
If a transaction to add ₹1000 to an account was committed but
not written to disk, the system redoes it from the log.

B. Rollback (Undo)

➤ Definition:
Rollback means undoing the changes of uncommitted
transactions to maintain consistency.

➤ Purpose:
To ensure that incomplete or failed transactions do not affect
the database.

➤ When is it used?
• When a transaction fails or is aborted
• During crash recovery, to undo uncommitted changes

➤ Process:
1. Identify uncommitted transactions from the log
2. Use the undo log to reverse their changes
3. Restore the database to a consistent state

➤ Example:

If a transaction was transferring money but the system crashed mid-way (after
debiting but before crediting), the system rolls back the debit.

You might also like