System Design
About Lesson

In order to scale the system to serve increasing number of clients, we would need multiple servers: one for web / mobile traffic (web tier) and one for database (data tier). This allows each to be scaled separately.

client server database

SQL vs NoSQL

Relational databases are structured and store data in tables having rows and columns. Most of these databases use Structured Query Language(SQL) for querying data. Most popular ones include MySQL, Oracle Database, Microsoft SQL Server.

A non-relational database is a database that does not use the tabular schema of rows and columns found in relational database systems. They generally don’t use SQL for querying data, and provide their own mechanism for storage and retrieval. This approach is called NoSQL.

Here are the most common types of NoSQL databases:

  • Key-Value Stores: Stores data as a collection of key-value pairs. Each data item is identified by a unique key, and the value associated with that key can be anything, such as a string, number, object, or even another data structure. Examples: Redis, DynamoDB, etc.
  • Graph Stores: Used to store and query highly connected data. Data can be modelled in the form of entities (also referred to as nodes, or vertices) and the relationships between those entities (also referred to as edges). The strength or nature of the relationships also carry significant meaning in graph databases. Examples: Neo4J, CosmosDB, etc.
  • Wide-Column Stores: Stores data in columns rather than rows, making it highly scalable and flexible. Data is organised into column families, which are groups of columns that share the same attributes. Each row is identified by a unique row key, and the columns in that row are further divided into column names and values. Examples: Cassandra, HBase, etc.
  • Document Stores: Data is stored in documents. Each document is typically a nested structure of keys and values. The values can be atomic data types, or complex elements such as lists, arrays, nested objects, or child collections. Example: CouchDB, MongoDB, etc.

When to use SQL?

  • When building an application structured around a relationship between data tables.
  • When building an application that needs ACID compliance. Generally, NoSQL databases sacrifice ACID compliance for latency and scalability, but for many financial applications, an ACID­ compliant database is essential.
  • When building an application where data is structured and somewhat static.

When to use NoSQL?

  • When building an application that requires low-latency.
  • Unstructured data.
  • When we need to store massive amounts of data.
  • When building an application in a fast, agile environment, NoSQL allow developers to be in control of the structure of the data allowing quick iterations, and frequent code pushes.
  • When you are using distributed storage / cloud computing, NoSQL makes it easier to distribute data across multiple servers.

 

Scroll to Top