Unit Iii
Unit Iii
What is NoSQL?
NoSQL Database is a non-relational Data Management System, that does not require a
fixed schema. It avoids joins, and is easy to scale. The major purpose of using a
NoSQL database is for distributed data stores with humongous data storage needs.
NoSQL is used for Big data and real-time web apps. For example, companies like
Twitter, Facebook and Google collect terabytes of user data every single day.
NoSQL database stands for “Not Only SQL” or “Not SQL.” Though a better term
would be “NoREL”, NoSQL caught on. Carl Strozz introduced the NoSQL concept in
1998.
The concept of NoSQL databases became popular with Internet giants like Google,
Facebook, Amazon, etc. who deal with huge volumes of data. The system response
time becomes slow when you use RDBMS for massive volumes of data.
To resolve this problem, we could “scale up” our systems by upgrading our existing
hardware. This process is expensive.
Brief History of NoSQL Databases
● 1998- Carlo Strozzi use the term NoSQL for his lightweight, open-
source relational database
● 2000- Graph database Neo4j is launched
● 2004- Google BigTable is launched
● 2005- CouchDB is launched
● 2007- The research paper on Amazon Dynamo is released
● 2008- Facebooks open sources the Cassandra project
● 2009- The term NoSQL was reintroduced
Key Features of NoSQL
NoSQL databases are often used in applications where there is a high volume of data that
needs to be processed and analyzed in real-time, such as social media analytics, e-
commerce, and gaming. They can also be used for other applications, such as content
management systems, document management, and customer relationship management.
1 Document databases
A document database stores data in JSON, BSON, or XML documents (not Word
documents or Google Docs, of course). In a document database, documents can be
nested. Particular elements can be indexed for faster querying.
Documents can be stored and retrieved in a form that is much closer to the data
objects used in applications, which means less translation is required to use the data in
an application. SQL data must often be assembled and disassembled when moving
back and forth between applications and storage.
Document databases are popular with developers because they have the flexibility to
rework their document structures as needed to suit their application, shaping their
data structures as their application requirements change over time. This flexibility
speeds development because, in effect, data becomes like code and is under the
control of developers. In SQL databases, intervention by database administrators may
be required to change the structure of a database.
The most widely adopted document databases are usually implemented with a
scale-out architecture, providing a clear path to scalability of both data volumes
and traffic.
Use cases include ecommerce platforms, trading platforms, and mobile app
development across industries.
2 Key-value stores
Use cases include shopping carts, user preferences, and user profiles.
3 Column-oriented databases
While a relational database stores data in rows and reads data row by row, a
column store is organized as a set of columns. This means that when you
want to run analytics on a small number of columns, you can read those
columns directly without consuming memory with the unwanted data.
Columns are often of the same type and benefit from more efficient
compression, making reads even faster. Columnar databases can quickly
aggregate the value of a given column (adding up the total sales for the year,
for example). Use cases include analytics.
A graph database focuses on the relationship between data elements. Each element
is stored as a node (such as a person in a social media graph). The connections
between elements are called links or relationships. In a graph database, connections
are first-class elements of the database, stored directly. In relational databases, links
are implied, using data to express the relationships.
A graph database is optimized to capture and search the connections between data
elements, overcoming the overhead associated with JOINing multiple tables in SQL.
Very few real-world business systems can survive solely on graph queries. As a result
graph databases are usually run alongside other more traditional databases.
Use cases include fraud detection, social networks, and knowledge graphs.
As you can see, despite a common umbrella, NoSQL databases are diverse in their
data structures and their applications.
Difference between Relational database and NoSQL
1. Relational Database :
RDBMS stands for Relational Database Management Systems. It is
most popular database. In it, data is store in the form of row that is in
the form of tuple. It contain numbers of table and data can be easily
accessed because data is store in the table.
2. NoSQL :
NoSQL Database stands for a non-SQL database. NoSQL database
doesn’t use table to store the data like relational database. It is used for
storing and fetching the data in database and generally used to store
the large amount of data. It supports query language and provides
better performance.
Relational Database NoSQL
It is used to handle data coming in low velocity. It is used to handle data coming in high velocity.
It gives only read scalability. It gives both read and write scalability.
Data arrives from one or few locations. Data arrives from many locations.
Its difficult to make changes in database once it is defined Enables easy and frequent changes to database
Views in SQL
Views are the logical and virtual copy of a table that is created by executing a ‘select query’
statement. The views are not stored anywhere on the disk. Thus, every time, a query has to be
executed when certain data is required. But, the query expression is stored on the disk.
Views do not have a storage/update cost associated with it. Views are designed with a specific
architecture, which means there is an SQL standard to define a view. Views are used when
data has to be accessed infrequently, but data gets updated frequently.
Materialized Views in SQL
Materialized views are the views whose contents are computed and stored. Materialized views are also
a logical virtual table, but in this case the result of the query is stored in the table or the disk. The
performance of the materialized views is better than normal views. This is because the data is stored on
the disk.
Sometimes, materialized views are also called as "indexed views" because the table created after the
query is indexed and can be accessed faster and efficiently. Materialized Views are used when data is to
be accessed frequently and data in table not get updated on frequent basis.