Comparing Relational Databases, Memory Cache, and NoSQL Databases
When we think of a database, what we traditionally envision is a relational database. This is a repository of structured data organized by schemas, tables, columns, and rows. Data is stored persistently, and will be resident on the system if the database application is restarted. Data in a relational database can be structured with constraints, so that all entries are required to contain consistent data (like a required field Name in a table of user account information). The tables also contains indexes that allow information from different tables to be linked and retrieved using SQL (Structured Query Language).
Relational databases have many advanced features, but for most web applications those features are underutilized. Databases are often used to store and present simple data structures (like user account information), rather than to perform complex operations across multiple tables. Relational databases also run into performance limitations when dealing with the massive volumes of data generated by the 'Big Data' traffic patterns of today. Because of performance bottlenecks from queries on relational databases, it is now common to deploy a memory cache server in conjunction with a database to improve performance.
A memory cache is an application that complements a database to improve performance by keeping frequently accessed data in system memory for quick retrieval. Requests are received by the server and are checked against the memory cache. Because memory cache data is stored in system memory, it is not persistent, meaning that it will not be retained if the memory cache server session is restarted. One of the most popular open source memory cache applications is memcached. Another application that can effectively be used for memory caching is Redis, a NoSQL database.
A NoSQL database is a non-relational database designed for fast performance with high volumes of data. It does not depend on SQL as the default query language, but that is not to say that it cannot use SQL to query data. Multiple servers can be added to a NoSQL cluster to distribute the workload, also known as a distributed array. There are four main categories of NoSQL databases, each with different strengths.
Key-Value Store, examples: Redis, Azure Table Storage
Document Store, examples: CouchDB, MongoDB
Wide Column Store, examples: Cassandra, Sqrrl Enterprise
Graph Databases, examples: Neo4j, sones
Working with constraints
In a Relational SQL database, constraints or required fields are enforced by the database schema to maintain an internally consistent data structure for searching using SQL queries. For example, in order for a user account record to be stored in a SQL database it can be required to enter a value for the fields FirstName, LastName, and EmailAddress before the entry is saved. A NoSQL database has less constraints on information that can be stored, and can save records for when only partial information is entered. The result is a performance boost as a result of that flexibility. One of the ways that a NoSQL database can store information is as a key-value pair.
What Are Key-Value Pairs?
A key-value pair is derived from hashing, or the transformation of a string of characters into shorter key that represents the original string. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value. Key-value stores also allow storage of schema-less data. A NoSQL database like Redis can store multiple data types as part of a key-value pair, including: strings, lists, sets, sorted sets, and hashes.
More Information on Non-Relational Databases
More information on the topic of non-relational databases can be found in the following article: Non-Relational Database Technologies
© 2015 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER