Why No SQL WP
Why No SQL WP
As a result, NoSQL databases are built from the ground up to be flexible, scalable, and
capable of rapidly responding to the data management demands of modern, digital
businesses.
This paper introduces the modern challenges that NoSQL databases address and
shows when to choose NoSQL over relational and why.
Today’s enterprises are interacting digitally – not only with their customers, but
also with their employees, partners, vendors, and even their products – at an
unprecedented scale.
These network, edge, and web-powered applications are at the heart of the NoSQL
revolution: the Internet of Things (IoT), social media, big data analytics, a company’s
internal or external cloud, mobile/edge computing, and more.
Bringing together all of these new systems requires more flexibility, performance,
and scalability that allows multiple types of systems to be consolidated into a single
platform.
NoSQL databases emerged as a result of the exponential growth of the internet and
the rise of web applications. Google Bigtable research was released in 2006, and
Amazon Dynamo research paper in 2007. Efficient distributed key-value (KV) engines
were essential to this evolutionary step and have propelled the technology much
further.
2
Agility meant providing flexible schemas, useful APIs, robust SQL-based querying,
text analytics, and more. While scalability allowed data volumes to grow and without
sacrificing performance and stability.
NoSQL systems hold hierarchical JSON data but return it to the application in the form
of full or partial JSON data structures, full-text search matches, tabular SQL query rows,
key-based objects, or even big data analytic systems.
For example, technical leaders are now expected to build enterprise data management
infrastructure that includes the following characteristics:
• Rapidly adapt to changing requirements with frequent updates and new features
SQL-based relational databases are unable to meet these new requirements whereas
NoSQL databases can.
Consider just a few examples of Global 2000 enterprises that are deploying NoSQL for
mission-critical applications that have been featured in recent news reports:
• Tesco, Europe’s no. 1 retailer deploys NoSQL for e-commerce, product catalog, and
other applications
• Ryanair, the world’s busiest airline uses NoSQL to power its mobile app serving over
3 million users
• Marriott deploys NoSQL for its reservation system that books $38 billion annually
• Viber, processes over 15B events per day for their over 1B customers
• GE deploys NoSQL for its Predix platform to help manage the industrial internet
3
Today’s trends – tomorrow’s challenges
Today’s customer experience goals depend on tightly aligned technical integration more
than ever before, but it must fit perfectly with the digital economy trends going forward
or risk becoming outdated.
• Effective data “plumbing” for real-time web applications and low latency
• Act as a service layer that pushes data as close to the customer as possible
Here are five trends that play into the advantages of NoSQL databases for addressing the
challenges of operating in a digital economy.
4
• Scaling on demand to support more
customers, and store more data
• Operating fully managed applications
4. Applications are moving to the cloud on a global scale to support customers
worldwide
• Minimizing infrastructure costs,
achieving a faster time to market
The above requirements are extensive and challenge even the best systems to do even
more with less. Today’s extreme requirements can be loosely grouped into two categories
that impact two different levels of end users:
All agile platforms provide a flexibility that allows faster, easier, application development.
Some of these benefits are in how the platform handles data, others are in how applications
can interact with the database.
5
Flexibility for faster development
By comparison, a NoSQL document database fully supports agile development, because
it is schema-less and does not statically define how the data must be modeled. Instead, it
defers to the applications and services, and thus to the developers as to how data should be
modeled. With NoSQL, the data model is defined by the application model. Applications and
services model data as objects.
Consider an application for managing resumes. It interacts with resumes as an object of user
objects. It contains an array for skills and a collection for positions. However, writing a resume
to a relational database requires the application to “shred” the user object.
6
Storing this resume would require the application to insert six rows into three tables, as
illustrated in Figure 3.
However, reading this profile would require the application to read six rows from three tables,
as illustrated in Figure 4.
Within those buckets are additional hierarchical logical groupings that can be restricted
to particular users or roles. These are called collections and/or scopes, allowing subsets of
documents in a bucket to be named. Because this flexibility helps segregate data of one user
or application from another, the developer does not have to build their own security and
reliability code, but can instead let the underlying database do it.
7
Querying using SQL
Application developers that are used to querying with SQL can continue to use the same
language in NoSQL platforms but operate against the JSON data that is stored. For example,
Couchbase provides a SQL-based query language known as N1QL that returns results in
JSON with sets of rows and subdocument components where appropriate. This is in contrast
to the vast majority of other NoSQL databases (like MongoDB™) that don’t use SQL and
require developers to climb a new language learning curve.
Standard statements are supported including SELECT .. FROM .. WHERE syntax. N1QL
also supports aggregation, sorting, and joins (GROUP BY .. SORT BY .. LEFT OUTER/
INNER JOIN). Querying collections, scopes, and even nested arrays is supported. Query
performance can be improved with composite, partial, covering indexes, and more.
There are minimal changes for SQL experts to move to N1QL where desired, with all the basic
queries working out of the box.
SQL N1QL
8
This is why NoSQL databases like Couchbase support transactions.
// Getting documents:
// Use ctx.getOptional if the document may or may not exist
Optional<TransactionGetResult> docOpt =
ctx.getOptional(collection, “doc-a”);
// Replacing a doc:
TransactionGetResult docB = ctx.get(collection, “doc-b”);
JsonObject content = docB.contentAs(JsonObject.class);
content.put(“transactions”, “are awesome”);
ctx.replace(docB, content);
// Removing a doc:
TransactionGetResult docC = ctx.get(collection, “doc-c”);
ctx.remove(docC);
ctx.commit();
});
The combination of transactions and SQL greatly expand the number of use cases where a
NoSQL database can be considered. In the past, the inability to join or handle transactional
operations meant that NoSQL databases were only chosen for the highest volume and scale
use cases. But the option of using SQL and transactions means that NoSQL databases can
also be chosen for traditional RDBMS cases that need more flexibility and power.
9
One data source – multiple access methods
NoSQL databases operate as a primary content store, meaning you enter the data in
one application but can access it multiple ways depending on the use case. For example,
developers can use direct API calls to access a specific document using a key or through a
SQL query that returns multiple rows of data in a JSON response.
Other access methods are available depending on the database, including full-text search
systems that allow natural language search requests. Requests can be made for full or partial
“fuzzy” matches, geographic ranges, or wildcard searches. The response includes a JSON
document with lists of matching document IDs, contextual information, and a relevancy
score.
Full-text search systems are often separate from a database but NoSQL databases like
Couchbase include them as part of the underlying system, allowing managers to simplify the
overall architecture.
Big data analytics are possible as well, using complimentary subsystems that process larger
volumes of historical data. Using advanced indexing and query capabilities, based on a
language known as SQL++, more advanced analytics can be done in the same database
without needing an external OLAP system.
Because the data is stored and indexed all within the one database product, it allows
developers to connect to one system and pass through the relevant requests.
The database has to be able to scale reads, writes, and storage. This is a problem for
relational databases that are limited to scaling up – i.e., only being able to scale by adding
more processors, memory, and storage to a single physical server. As a result, the ability to
scale efficiently, and on demand, is a challenge. It becomes increasingly expensive, because
enterprises have to purchase bigger and bigger servers to accommodate more users and
more data. In addition, it can result in downtime if the database has to be taken offline to
perform hardware upgrades.
10
A distributed NoSQL database, however, leverages commodity hardware to scale out – i.e.,
add more resources simply by adding more servers to a cluster. The ability to scale out
enables enterprises to scale more efficiently by (a) deploying no more hardware than is
required to meet the current load; (b) leveraging less expensive hardware and/or cloud
infrastructure; and (c) scaling on demand and without downtime.
By distributing reads, writes, and storage across a cluster of nodes, NoSQL databases are
able to operate at any scale. Additionally, they are designed to be easy to configure, install,
and manage both small and large clusters.
11
Customer behavior now requires organizations to support multiple physical, online and
mobile channels in multiple regions and often multiple countries. While deploying a
database to multiple data centers increases availability and helps with disaster recovery, it
also has the benefit of increasing performance too. All reads and writes can be executed on
the nearest data center, thereby reducing latency.
Ensuring global availability is difficult for relational databases where separate add-ons are
required – which increase complexity – or where replication between multiple data centers
can only be used for failover, because only one data center is active at a time. Oracle, for
example, requires Oracle GoldenGate. When replicating between data centers, applications
built on relational databases can experience performance degradation or find that the data
centers are severely out of sync.
Deploying to multiple data centers not only improves performance, but enables immediate
failover via hardware routers. Applications don’t have to wait for the database to discover
the failure and perform its own failover.
12
NoSQL is a better fit for digital economy requirements
As enterprises shift to the digital economy – enabled by cloud, mobile, social media, and
big data technologies – developers and operations teams have to build and maintain web,
mobile, and IoT applications faster and faster, and at a greater scale. NoSQL is increasingly
the preferred database technology to power today’s web, mobile, and IoT applications.
Hundreds of Global 2000 enterprises, along with tens of thousands of smaller businesses
and startups, have adopted NoSQL. For many, the use of NoSQL started with an open
source cache, proof of concept or a small application, then expanded to targeted mission-
critical applications, and is now the foundation for all application development. Today, the
Couchbase NoSQL database serves thousands of these types of customers.
With NoSQL, enterprises are better able to both develop with agility and operate at any
scale – and to deliver the performance and availability required to meet the demands of
digital economy businesses.
About Couchbase
Unlike other NoSQL databases, Couchbase provides an enterprise-class, multicloud to edge database that offers
the robust capabilities required for business-critical applications on a highly scalable and available platform. As
a distributed cloud-native database, Couchbase runs in modern dynamic environments and on any cloud, either
customer-managed or fully managed as-a-service. Couchbase is built on open standards, combining the best of
NoSQL with the power and familiarity of SQL, to simplify the transition from mainframe and relational databases.
Couchbase has become pervasive in our everyday lives; our customers include industry leaders Amadeus, American
Express, Carrefour, Cisco, Comcast/Sky, Disney, eBay, LinkedIn, Marriott, Tesco, Tommy Hilfiger, United, Verizon, as well
as hundreds of other household names. For more information, visit www.couchbase.com.
© 2021 Couchbase. All rights reserved.