NoSQL
Web Technologies
What is a NoSQL database?
• When people use the term “NoSQL database,” they typically use it to
refer to any non-relational database.
• Some say the term “NoSQL” stands for “non SQL” while others say it
stands for “not only SQL.”
• Either way, most agree that NoSQL databases are databases that
store data in a format other than relational tables.
what is a NoSQL database?
• NoSQL database technology stores information in JSON documents
instead of columns and rows used by relational databases.
• To be clear, NoSQL stands for “not only SQL” rather than “no SQL” at
all. This means a NoSQL JSON database can store and retrieve data
using literally “no SQL”
• you can combine the flexibility of JSON with the power of SQL for the
best of both worlds. Consequently, NoSQL databases are built to be
flexible, scalable, and capable of rapidly responding to the data
management demands of modern businesses.
NoSQL database features
• Each NoSQL database has its own unique features. At a high level,
many NoSQL databases have the following features:
• Flexible schemas
• Horizontal scaling
• Fast queries due to the data model
• Ease of use for developers
Types of NoSQL Databases
Four most-popular types of NoSQL database:
• Document databases are primarily built for storing information as documents,
including, but not limited to, JSON documents. These systems can also be used for
storing XML documents, for a NoSQL database example.
• Key-value stores group associated data in collections with records that are
identified with unique keys for easy retrieval. Key-value stores have just enough
structure to mirror the value of relational databases (as opposed to non-relational
databases) while still preserving the benefits of the NoSQL database structure.
• Wide-column databases use the tabular format of relational databases yet allow a
wide variance in how data is named and formatted in each row, even in the same
table. Like key-value stores, wide-column databases have some basic NoSQL
structure while also preserving a lot of flexibility
• Graph databases use graph structures to define the relationships between stored
data points. Graph databases are useful for identifying patterns in unstructured
and semi-structured information.
When should NoSQL be used?
• following factors lead them to selecting a NoSQL database:
• Fast-paced Agile development
• Storage of structured and semi-structured data
• Huge volumes of data
• Requirements for scale-out architecture
• Modern application paradigms like microservices and real-time
streaming
New technical challenges that NoSQL DBs
address
Digital Economy trends Requirements
• Scaling to support thousands, if not millions, of users
1. More customers are going
• Meeting UX requirements with consistent high performance
online
• Maintaining availability 24 hours a day, 7 days a week
• Supporting many different things with different data structures
. The internet is connecting
• Supporting hardware/software updates, generating different data
everything
• Supporting continuous streams of real-time data
• Storing customer generated semi-structured/unstructured data
3. Big data is getting bigger • Storing different types of data from different sources, together
• Storing data generated by thousands/millions of customers/things
• Scaling on demand to support more customers, store more data
4. Applications are moving to
• Operating applications on a global scale – customers worldwide
the cloud
• Minimizing infrastructure costs, achieving a faster time to market
• Creating “offline first” apps – network connection not required
5. The world has gone mobile • Synchronizing mobile data with remote databases in the cloud
• Supporting multiple mobile platforms with a single backend
Example model
Differences between SQL and NoSQL are:
SQL NoSQL
Stands for Structured Query Language Stands for Not Only SQL
Relational database management system (RDBMS) Non-relational database management system
Suitable for structured data with predefined schema Suitable for unstructured and semi-structured data
Data is stored in tables with columns and rows Data is stored in collections or documents
Follows ACID properties (Atomicity, Consistency, Isolation,
Does not necessarily follow ACID properties
Durability) for transaction management
Supports JOIN and complex queries Does not support JOIN and complex queries
Uses normalized data structure Uses denormalized data structure
Horizontal scaling is possible to handle large volumes of
Requires vertical scaling to handle large volumes of data
data
Examples: MySQL, PostgreSQL, Oracle, SQL Server, Examples: MongoDB, Cassandra, Couchbase, Amazon
Microsoft SQL Server DynamoDB, Redis
Query Mechanism Tools For NoSQL
• The REST-based retrieval of a value based on its key/ID with the GET
resource is the most frequent data retrieval mechanism.
• Because they grasp the value in a key-value combination, document
store databases allow for more challenging searches.
• With MapReduce, CouchDB, for example, allows you to define views.
CAP theorem
• Brewer's theorem is another name for the CAP theorem. It claims that
a distributed data store cannot provide more than two out of three
guarantees.
• 1)Consistency
• 2)Availability
• 3)Partition Tolerance
Cont…
• 1)Consistency:
• Even after an operation has been completed, the data should stay consistent. This
indicates that once data is written, it should be included in any subsequent read
requests. After altering the order status, for example, all clients should be able to
see the same information.
• 2)Availability:
• The database should be accessible and responsive at all times. There should be no
downtime.
• 3)Partition Tolerance:
• Partition Tolerance means that the system should keep working even if connection
between the servers isn't always reliable. The servers, for example, can be divided
into several groups that may or may not communicate with one another. If one
portion of the database is down, the other sections are always up and running.
What is MongoDB?
• MongoDB is a document database used to build highly available and
scalable internet applications.
• MongoDB is an open-source document database built on a horizontal
scale-out architecture that uses a flexible schema for storing data.
Founded in 2007, MongoDB has a worldwide following in the
developer community.
• MongoDB database is a document described in BSON, a binary
representation of the data. Applications can then retrieve this
information in a JSON format.
Why Use MongoDB?
• Document Model :
• The document data model is a powerful way to store and retrieve
data in any modern programming language, allowing developers to
move quickly.
• Deployment Options
• MongoDB is available in any major public cloud (such as AWS, Azure,
and Google Cloud) through MongoDB Atlas, in large data centers
through the Enterprise Advanced edition, or free through the
open-source Community edition.
Cont…
• Fully Scalable
• MongoDB’s horizontal, scale-out architecture can support huge
volumes of both data and traffic.
• Find Community
• MongoDB has developed a large and mature platform ecosystem. It
has a worldwide community of developers and consultants, making it
easy to get help. It also has an enterprise-grade support offering.