0% found this document useful (0 votes)
7 views7 pages

Nosql Unit 3

The document provides an overview of various types of non-relational databases, including key-value, document, column family, and graph databases, highlighting their features, advantages, and use cases. Key-value databases are simple and scalable, document databases offer flexible schemas, column family databases excel in analytics, and graph databases focus on relationships between data. Each database type has unique characteristics, consistency models, and applications suited for different data management needs.

Uploaded by

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

Nosql Unit 3

The document provides an overview of various types of non-relational databases, including key-value, document, column family, and graph databases, highlighting their features, advantages, and use cases. Key-value databases are simple and scalable, document databases offer flexible schemas, column family databases excel in analytics, and graph databases focus on relationships between data. Each database type has unique characteristics, consistency models, and applications suited for different data management needs.

Uploaded by

Harsh Mukati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Key-Value Database

A key-value database is also referred to as a key-value store A key-value store is a nonrelational database. The
simplest form of a NoSQL database is a key-value store. Every data element in the database is stored in key-value
pairs. The data can be retrieved by using a unique key allotted to each element in the database. The values can be
simple data types like strings and numbers or complex objects. Exa - Amazon DynamoDB
Features / Advantages:

 One of the most un-complex kinds of NoSQL data models.


 For storing, getting, and removing data, key-value databases utilize simple functions.
 It is very easy to use. Due to the simplicity of the database, data can accept any kind, or even different kinds
when required.
 Its response time is fast due to its simplicity.
 Key-value store databases are scalable vertically as well as horizontally.
 Built-in redundancy makes this database more reliable.

1. Consistency :- In distributed key-value stores, ensuring that all replicas have the same data after an update is a
challenge. Consistency models dictate how data updates are propagated across nodes.
● Eventual Consistency: Many distributed key-value stores (e.g., Amazon DynamoDB, Cassandra) offer eventual
consistency, meaning updates to data will propagate across all nodes over time. At some point, all replicas will
converge to the same state, but during this period, some nodes may serve stale data.
● Strong Consistency: Some key-value databases (e.g., Redis when configured with replication) provide options for
strong consistency, ensuring that an update is immediately visible to all clients across all replicas. Key-value stores
often offer tunable consistency, where you can choose between strong or eventual consistency based on
performance and availability trade-offs.

2. Partitioning (Sharding) :- Partitioning is crucial for distributing data across multiple nodes or servers, allowing key-
value stores to scale horizontally.
● RangePartitioning: Some key-value databases partition data by dividing keys into ranges (e.g., alphabetically or
numerically) and assigning different ranges to different nodes.
● Hash-Based Partitioning: In hash-based partitioning, the system applies a hash function to the key, and the
resulting hash value determines the partition or node that will store the data. Partitioning enhances scalability but
also introduces challenges like handling cross-partition queries or ensuring that updates across multiple partitions
are consistent.

3. Scaling :- Key-value databases are typically designed for easy horizontal scaling.
● Horizontal Scaling: Key-value stores can easily scale horizontally by adding more nodes. Partitioning strategies
ensure that as new nodes are added, the data is redistributed across these nodes without disrupting the system.
● Auto-Scaling: In managed key-value stores (e.g., Amazon DynamoDB), auto-scaling mechanisms automatically
adjust capacity based on the workload. This is done by monitoring read/write operations and scaling the
infrastructure to meet demand.
● Elasticity: Many key-value stores are elastic, meaning they can automatically adapt to varying loads by adding or
removing nodes without manual intervention.

4. Replication :- Replication in key-value stores ensures high availability and fault tolerance by maintaining copies of
data across multiple nodes or data centers.
● Master-Slave Replication: Some systems (e.g., Redis with replication) use master-slave replication, where the
master handles writes, and the slaves replicate the data to ensure redundancy. If the master fails, a slave can be
promoted to master.

Use Cases:
Caching: Key-value stores like Redis are widely used for caching purposes to improve application performance.
Session Storage: They are used to store user sessions, where the session ID is the key, and the session data is the
value.
Real-Time Analytics: Key-value stores can handle high-speed, large-scale data for real-time applications.
Shopping Carts: E-commerce systems use key-value stores to maintain user-specific shopping cart data, where the
user ID is the key, and the cart contents are the value
Document Databse: The document-based database is a nonrelational database. Instead of storing the data in rows
and columns (tables), it uses the documents to store the data in the database. A document database stores data in
JSON, BSON, or XML documents.In the Document database, the particular elements can be accessed by using the
index value that is assigned for faster querying. Document databases are designed to handle large volumes of data
with varied structures, making them suitable for applications requiring flexibility, scalability, and fast access to data
EXAMPLE - MongoDB
Features / Advantages:
 Document Type Model: As we all know data is stored in documents rather than tables or graphs, so it
becomes easy to map things in many programming languages.
 Flexible Schema: Overall schema is very much flexible to support this statement one must know that not all
documents in a collection need to have the same fields.
 Key-Value Access: Documents can be accessed using a unique identifier (often referred to as a document ID),
enabling quick retrieval without the need for complex queries.
 High Performance and Scalability: Document databases are designed to handle high volumes of read and
write operations efficiently. They can scale horizontally by distributing data across multiple servers.
 Faster creation of document and maintenance: It is very simple to create a document and apart from this
maintenance requires is almost nothing.

Feature Document Database Key-Value Database


Stores data as documents (often in JSON or
Data Structure Stores data as key-value pairs
BSON format)
Simple, flat structure (key maps to a
Data Model Hierarchical and nested structures
single value)
Example Use Content management, e-commerce, user Caching, session management, real-time
Cases profiles data feeds
Supports rich querying, filtering, and Limited querying (usually only supports
Query Flexibility
indexing key lookups)
Scalability Horizontally scalable Horizontally scalable
Allows retrieval of specific fields within a Retrieves the entire value associated with
Data Retrieval
document a key
MongoDB, Couchbase, Amazon Redis, DynamoDB (in key-value mode),
Examples
DocumentDB Memcached
Transaction Often supports ACID transactions within a
Limited or no transaction support
Support document
Storage Efficiency Optimized for document-based data storage Highly optimized for key-value storage

Scaling in document database :-


Horizontal Scalability :- Document databases excel at horizontal scaling, which involves adding more servers to
distribute the load rather than upgrading a single server (vertical scaling). This approach allows for efficient
management of substantial data volumes and high traffic, making them ideal for applications that experience rapid
growth or fluctuating workloads

Partition in document database :- Partitioning in a document database refers to the technique of dividing data into
smaller, manageable segments, known as partitions. This approach enhances performance, scalability, and
maintenance of the database.
Types of Partitioning
1. Horizontal Partitioning: Rows (or documents) are divided across multiple partitions based on a specific criterion
(e.g., a range of values, a specific attribute).
2. Vertical Partitioning: Documents are divided based on fields or attributes, with each partition containing only a
subset of the total fields.

Sharding in document database :- Sharding in a document database is a method used to distribute data across
multiple servers or nodes to improve scalability and performance. Here’s an overview of sharding, its concepts,
benefits, and implementation in document databases:
What is Sharding :- Sharding involves splitting a large dataset into smaller, more manageable pieces called shards.
Each shard is an independent database that contains a subset of the data. This allows the database to scale
horizontally by adding more servers as the dataset grows.
Sharding Key: Aspecific field used to determine how data is distributed across shards. Choosing an effective sharding
key is crucial for balanced data distribution.
Shard: Eachshard operates as a standalone database. It holds a portion of the overall data and can be queried
independently.
Consistency in document database :- Document databases typically utilize eventual consistency, which allows for
temporary inconsistencies in exchange for improved performance and scalability. This model ensures that, over time,
all copies of the data will converge to the same value, but immediate consistency is not guaranteed. This is
particularly useful for applications where high availability is prioritized over real-time accuracy, such as social media
platforms and content management systems
● StrongConsistency: Some document databases can provide strong consistency, ensuring that all users see the most
recent data at any given time. This is essential for applications requiring immediate accuracy, like financial
transactions.
● WeakConsistency: In contrast, weak consistency means that different nodes mayreturn different values for the
same data at any moment. This can lead to scenarios where users access outdated information, which is acceptable
in use cases where real-time accuracy is not critical.
Use Cases for Document Databases
1. Content Management Systems :- Document databases are ideal for content management applications, such as
blogs, news websites, and streaming platforms. Each piece of content can be stored as a single document, making it
easy to manage, update, and retrieve information as the application evolves. The flexible schema allows for different
types of content (e.g., text, images, videos) to be stored without requiring a rigid structure.
2. E-commerce Catalogs :- In e-commerce applications, products often have different attributes (e.g., size, color,
specifications). Document databases allow each product to be stored as a document containing all its relevant
details, facilitating efficient retrieval and management of complex catalogs without the limitations of relational
databases.
3. Mobile Applications :- Due to their flexible schema and ability to handle varying data structures, document
databases are often used in mobile applications where user-generated content (like comments or posts) can vary
significantly in format and structure
4. Real-time Analytics: Suitable for applications that need to handle large amounts of data quickly, such as social
media feeds or IoT data

Column Family Database


A column-oriented database is a non-relational database that stores the data in columns instead of rows. That means
when we want to run analytics on a small number of columns, you can read those columns directly without
consuming memory with the unwanted data. Columnar databases are designed to read data more efficiently and
retrieve the data with greater speed. A columnar database is used to store a large amount of data.
It’s designed for high performance on large datasets and is optimized for read/write operations across rows and
columns. This model is inspired by Google’s Bigtable and is commonly used in distributed, scalable systems.
Key features of columnar oriented database: Scalability. Compression. Very responsive.
Exam- Casandra
Advantages of Columnar Data Model :
 Well structured: Since these data models are good at compression so these are very structured or well
organized in terms of storage.
 Flexibility: A large amount of flexibility as it is not necessary for the columns to look like each other, which
means one can add new and different columns without disrupting the whole database
 Aggregation queries are fast: The most important thing is aggregation queries are quite fast because a
majority of the information is stored in a column. An example would be Adding up the total number of
students enrolled in one year.
 Scalability: It can be spread across large clusters of machines, even numbering in thousands.
 Load Times: Since one can easily load a row table in a few seconds so load times are nearly excellent.

Consistency
Column Family Databases often support eventual consistency but can be configured for strong consistency
depending on requirements. Consistency models vary, with some databases allowing for tunable
consistency levels, where users can choose the level of consistency (e.g., quorum-based) based on the
operation.
Transactions
Transactions in Column Family Databases may be limited in scope:
 Lightweight Transactions: Some databases support limited ACID transactions within a single row or
column family, which allows atomic operations on specific data subsets.
 Eventual Consistency: For cross-node or distributed transactions, consistency may be relaxed, using
BASE principles (Basically Available, Soft-state, Eventually consistent) rather than strict ACID.

Scaling
 Horizontal Scalability: Column Family Databases are designed for horizontal scaling across multiple
servers or nodes.
 Sharding and Partitioning: Data is partitioned across nodes, allowing for increased capacity and
performance.
 Replication: Multiple copies of data can be maintained for fault tolerance and higher availability.

Use Cases
 Data Analytics: Due to efficient read operations and column-oriented storage, column family
databases are ideal for analytical applications.
 Time-Series Data: Suitable for storing and querying time-stamped data, such as logs, sensor data,
and performance metrics.
 Content Management Systems: Useful for managing content where data can vary significantly in
structure, and fast read/write operations are needed.
 Real-Time Applications: Works well for applications requiring fast retrieval and scalability, such as
recommendation engines and ad tech solutions

Graph database
Graph-based databases focus on the relationship between the elements. It stores the data in the form of nodes in
the database.The connections between the nodes are called links or relationships. A key concept of the system is
the graph. Graph databases hold the relationships between data as a priority
Examp- Neo4j ,Graph base
Advantages / features of Graph Database:
 No joins are required since relationships is already specified.
 it is easy to identify the relationship between the data by using the links.
 The speed depends upon the number of relationships among the database elements.
 Updating data is also easy
 It is flexible and agile.
 it is easy to manage the data in terms of graph.
 High performance: Graph databases are optimized for handling large and complex datasets, making them
well-suited for applications that require high levels of performance and scalability.
 Scalability: Graph databases can be easily scaled horizontally, allowing additional servers to be added to the
cluster to handle increased data volume or traffic.
 Easy to use: Graph databases are typically easier to use than traditional relational databases. They often have
a simpler data model and query language, and can be easier to maintain and scale.
 ACID Compliance: Many graph databases offer ACID properties, ensuring reliable transactions and data
integrity.
Consistency
Graph databases often support strong consistency within single transactions, allowing nodes and relationships to
remain consistent even during complex updates. Some may also offer eventual consistency for highly distributed
setups to balance consistency and performance.
Transactions
Graph databases typically support ACID transactions, ensuring reliable operations for read and write consistency.
Transactions can be managed across nodes and relationships, which is essential for applications that require data
accuracy and integrity, such as financial applications or fraud detection.
Availability
 High Availability: Data replication and distributed architecture enhance availability.
 Fault Tolerance: Data is often replicated across nodes, providing resilience against node failures.
Scaling
 Horizontal Scalability: Graph databases can be distributed across multiple servers, allowing for the
management of large datasets.
 Partitioning: Data can be partitioned by separating different parts of the graph, though this can be
challenging due to the connected nature of data.

1. Directed Graphs (Digraphs) :- A directed graph is a graph in which edges have a specific direction. Each edge is
represented as an ordered pair of vertices (Vi,Vj)(vi,vj), indicating that there is a connection from vertex Vi vi to vertex
Vj vj. This directionality means that traversal is only possible in the specified direction.
Characteristics:
Indegree and Outdegree: Each vertex has an indegree (number of incoming edges) and an outdegree (number of
outgoing edges) .
Examples: Social media platforms (e.g., Twitter), where following someone does not imply they follow you back, and
web page links that point from one page to another.
2.Undirected Graphs :- In an undirected graph, edges have no direction; they simply connect two vertices without
indicating a specific flow. Each edge is represented as an unordered pair {Vi,Vj}{vi,vj}.
Characteristics:
Traversal can occur in both directions, meaning if there is an edge between Vi vi and Vj vj, you can travel from Vi vi to
Vj vj and vice versa.
Examples: Social networks where friendships are mutual, such as Facebook, where if person A is friends with person
B, then person B is also friends with person A.

3.Bipartite Graphs :- A bipartite graph is a type of graph where the set of vertices can be divided into two distinct
sets such that no two graph vertices within the same set are adjacent. This means that edges only connect vertices
from one set to vertices in the other set.A bipartite graph can be colored using two colors without adjacent vertices
sharing the same color.
Applications: Commonly used in modeling relationships between two different classes of objects.

4.Multigraphs :- A multigraph is a type of graph that allows multiple edges between the same pair of vertices. This
means that there can be more than one edge connecting two nodes.Unlike simple graphs, which have at most one
edge between any two vertices, multigraphs can represent more complex relationships. Edges in a multigraph can
also have weights or labels, enhancing their descriptive power.
Applications: Useful in scenarios where relationships are not uniquely defined, such as: ● Transportation networks
(multiple routes between cities). ● Communication networks (multiple connections between devices).

5.Weighted Graphs :- A weighted graph is a graph in which each edge is assigned a numerical value known as a
weight. These weights can represent various metrics such as distance, cost, or time. Weighted graphs can be either
directed or undirected.

Types:
Edge-weighted Graphs: Weights are assigned to edges only.

Vertex-weighted Graphs: Weights are assigned to vertices instead.

● Applications: Widely used in optimization problems and real-world scenarios such as:

● Shortest path algorithms ● Network flow problems

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy