NoSQL DB
1. Relational databases criticisms
1.1 Lots of new databases have emerged in the past few years, often because...
object-relational mapping can be complex or costly
relational databases do not play well with dynamically structured data and often-varying schemas
overhead of SQL parsing and full-blown query engines may be significant for simple access patterns(primary key access, BLOB storage etc.)
scaling to many servers with the ACID(Atomicity, Consistency, Isolation, Durability) guarantees provided by relational databases is hard
2. NoSQL and NewSQL databases
2.1many of the recent databases are labelled
NoSQL(the non-relational ones) or
NewSQL(the relational ones)
2.2 because they provide alternative solutions for some of the mentioned problems
2.3 especially the NoSQL ones often sacrifice features that relational db have in their DNA
3. NoSQL Database Types
Document databases pair each key with a complex data structure known as a document. Documents can contain many different key-value pairs, or key-array pairs, or even nested documents.
Graph stores are used to store information about networks of data, such as social connections. Graph stores include Neo4J and Giraph.
Key-value stores are the simplest NoSQL databases. Every single item in the database is stored as an attribute name (or 'key'), together with its value. Examples of key-value stores are Riak and Berkeley DB. Some key-value stores, such as Redis, allow each value to have a type, such as 'integer', which adds functionality.
Wide-column stores such as Cassandra and HBase are optimized for queries over large datasets, and store columns of data together, instead of rows.
Auto-sharding, Replication, Integrated Caching
NoSQL VS. SQL Summary
SQL Databases
NoSQL Databases
Types
One type (SQL database) with minor variations
Development History
Developed in 1970s to deal with first wave of data storage applications
Developed in late 2000s to deal with limitations of SQL databases, especially scalability, multi-structured data, geo-distribution and agile development sprints
Examples
MySQL, Postgres, Microsoft SQL Server, Oracle Database
MongoDB, Cassandra, HBase, Neo4j
Data Storage Model
Individual records (e.g., 'employees') are stored as rows in tables, with each column storing a specific piece of data about that record (e.g., 'manager,' 'date hired,' etc.), much like a spreadsheet. Related data is stored in separate tables, and then joined together when more complex queries are executed. For example, 'offices' might be stored in one table, and 'employees' in another. When a user wants to find the work address of an employee, the database engine joins the 'employee' and 'office' tables together to get all the information necessary.
Varies based on database type. For example, key-value stores function similarly to SQL databases, but have only two columns ('key' and 'value'), with more complex information sometimes stored as BLOBs within the 'value' columns. Document databases do away with the table-and-row model altogether, storing all relevant data together in single 'document' in JSON, XML, or another format, which can nest values hierarchically.
Schemas
Structure and data types are fixed in advance. To store information about a new data item, the entire database must be altered, during which time the database must be taken offline.
Typically dynamic, with some enforcing data validation rules. Applications can add new fields on the fly, and unlike SQL table rows, dissimilar data can be stored together as necessary. For some databases (e.g., wide-column stores), it is somewhat more challenging to add new fields dynamically.
Scaling
Vertically, meaning a single server must be made increasingly powerful in order to deal with increased demand. It is possible to spread SQL databases over many servers, but significant additional engineering is generally required, and core relational features such as JOINs, referential integrity and transactions are typically lost.
Horizontally, meaning that to add capacity, a database administrator can simply add more commodity servers or cloud instances. The database automatically spreads data across servers as necessary.
Development Model
Mix of open technologies (e.g., Postgres, MySQL) and closed source (e.g., Oracle Database)
Open technologies
Supports multi-record ACID transactions
Yes
Data Manipulation
Specific language using Select, Insert, and Update statements, e.g. SELECT fields FROM table WHERE…
Through object-oriented APIs
Consistency
Can be configured for strong consistency
Depends on product. Some provide strong consistency (e.g., MongoDB, with tunable consistency for reads) whereas others offer eventual consistency (e.g., Cassandra).
Last updated
Was this helpful?