NoSQL Database
NoSQL Database
Loan Status
NoSQL:
Since NoSql is classified into four types, let’s discuss this example by taking a
Document Database.
The customer’s entire record, including his loan details, can be stored within a
JSON document in the document database. All the attributes, including
Account Number, Name, Phone Number, Loan_Id, Loan Amount, and Loan
status, can be stored inside a single document for a particular customer.
NoSQL Database Management Systems are mainly used to deal with Big
data that are not necessarily structured or related.
Features of NoSQL
1. Multi-Model:
Unlike relational databases, where data is stored in relations, different data
models in NoSQL databases make them flexible to manage data. Each data
model is designed for specific requirements.
Examples of data models include document, graph, wide-column, and key-
value.
The concept is to allow multiple data models in a single database. By doing
so, the need for deploying and managing different databases for the same
data cancels out.
2. Distributed
NoSQL databases use the shared-nothing architecture, implying that the
database has no single control unit or storage. The advantage of using a
distributed database is that data is continuously available because data
remains distributed between multiple copies. On the contrary, Relational
Databases use a centralized application that depends on the location.
3. Flexible Schema
Unlike relational databases where data is organized in a fixed schema,
NoSQL databases are quite flexible while managing data. While relational
databases were built typically to manage structured data, NoSQL databases
can process structured, semi-structured or unstructured data with the same
ease, thereby increasing performance.
4. Eliminated Downtime
One of the essential features is the eliminated downtime. Since the data is
maintained at various nodes owing to its architecture, the failure of one node
will not affect the entire system.
5. High Scalability
One of the reasons for preferring NoSQL databases over relational databases
is their high scalability. Since the data is clustered onto a single node in a
relational database, scaling up poses a considerable problem. On the other
hand, NoSQL databases use horizontal scaling, and thus the data remains
accessible even when one or more nodes go down.
What do NoSQL databases have in
common?
1. They use distributed databases, which are based on shared-nothing
architecture.
2. NoSQL databases can easily be scaled out horizontally, depending on the
volumes of data.
3. All of the NoSQL databases have a flexible schema.
4. Furthermore, they process: structured, semi-structured as well as non-
structured data.
5. Lastly, the format of storing data is different from relational databases hence
are non-relational.
This is the simplest type of NoSQL database.Under this type, the data is
stored in the form of key/value pairs. For each Key, there is a value assigned
to it. Each Key is unique and accepts only strings, whereas the value
corresponding to the particular Key can accept String, JSON, XML, etc. Owing
to this behavior, it is capable of dealing with massive loads of data.
Key Value Stores maintain data as pair consisting of an index key and a
value. KV stores query Values using the index Key. Every item in the
database is stored in the pairs of Keys (Indexes) and Values. KV stores
resemble a relational database but with each table having only two columns.
Some KV stores may even allow basic joins to help you scan through if there
are composite joins, they may not be a suitable options.
There are multiple KV Stores available, each differing mainly in their adaption
of the CAP theorem and their configurations of memory v/s storage usage.
KV stores have fast query performance and are best suited for applications
that require content caching, e.g. a gaming website that constantly updates
the top 10 scores & players.
Key-Value Pairs Database: Features:
1. Consistency
2. Transactions
3. Query Features
4. Data Structure
5. Scaling
Pros:
– Simple Data model
– Scalable
– Value can include JSON, XML, flexible schemas
– Extremely Fast Owing to it’s simplicity
– Best fit for cases where data is not highly related
Cons:
– No relationships, create your own foreign keys
– Not suitable for complex data
– Lacks Scanning Capabilities
– Not ideal for operations rather than CRUD (create, read, update Delete )
2. Document Stores
Cons:
– Not suitable for relational data
– Querying limited to keys & indexes
– Map Reduce for more significant queries
Wide column data stores take a hybrid approach mixing the declarative
characteristics game of relational databases with the key-value pair based
and totally variables schema of key-value stores. Wide Column databases
stores data tables as sections of columns of data rather than as rows of data.
Columnar Family databases have their origins in Google’s Bigtable. According
to Google’s paper on Bigtable, “A Bigtable is a sparse, distributed, persistent
multidimensional sorted map.” This definition might leave you confused, just
as I was, it was all greek to my RDBMS oriented mind.
Here is a more simplified explanation, a column family data store is a multi-
dimensional key value store (map or associative array) which is persistent
(values persist after creation or access), distributed (data is distributed across
multiple computing & storage nodes), sorted (sorted keys) and sparse (values
for certain dimensions may not be populated, similar to sparsely populated
rows in RDBMS).
The multi-dimensional aspect of column stores brings in another concept of
column families.
Column-family databases store data in column families as rows that have
many columns associated with a row key. Column families are groups of
related data that is often accessed together.
There are two types of column families:
1. Standard Column family: Standard Column family consists of a key-value pair,
where the key is mapped to a value that is a set of columns. In analogy with
relational databases, a standard column family is as a “table”, each key-value
pair being a “row”.
2. Super Column family: Super Column family consists of a key-value pair,
where the key is mapped to a value that are column families. In analogy with
relational databases, a super column family is something like a “view” on a
number of tables. It can also be seen as a map of tables.
4. Graph Databases
Pros:
– Extremely powerful
– Connected data is locally indexed
– Can provide ACID
– Results in real-time
– Agile Structure
Cons:
– Difficult to scale out, though can scale up