Summary
Highlights
Relational databases like MySQL are designed to store relational data efficiently. They maintain complex relationships between tables, which is excellent for data management but significantly hinders their ability to scale horizontally. They can only scale vertically to a certain extent, meaning upgrading a single server becomes insufficient for heavy loads.
NoSQL databases achieve superior scalability by eliminating costly relationships. They operate as key-value stores where each item is independent. The value can be a complex JSON document. This simpler design allows for horizontal scaling by splitting the workload across multiple servers, a process called partitioning.
NoSQL databases use a primary key and a hash function to determine on which partition an item is stored. This hash value maps to a keyspace, which is a range of numbers. When a database needs to scale, the keyspace can be split across multiple servers, doubling capacity in terms of storage and query execution.
A key advantage of NoSQL is its schemaless nature, meaning items don't need a predefined structure. This contrasts with relational databases where schema changes can be complex and risky. The flexibility of a schemaless design is beneficial for applications with evolving data structures.
NoSQL databases have limitations. They are less flexible in data retrieval, primarily allowing access only via primary keys. Complex queries like finding items based on specific criteria can be inefficient. Additionally, NoSQL databases are eventually consistent, meaning a newly written item might not be immediately available due to background replication across mirrored partitions, though this usually resolves in milliseconds.
Cloud providers heavily utilize NoSQL (e.g., AWS DynamoDB, Google Cloud BigTable, Azure CosmosDB) due to their scalability. Open-source options include Cassandra, Scylla, CouchDB, and MongoDB. The term "NoSQL" alternately means "not only SQL" (indicating some SQL compatibility) or "non-relational" (referring to its handling of data).