Part 6 of Yogita Sharma System Design Tutorial: Databases types: SQL, NoSQL, Column, Search, Key Value.
This video covers:
- Types of Databases
- Pros and Cons
- Use Cases
- Examples
Depending on the properties of the data and the volume of data that may need to be queried - different types of databases are commended for use. Different types of databases include:
- Relational
- Non-relational
- File
- Network
Non-relational databases can be further subdivided into:
- Key-Value Stores
- Column based DBs
- Document based DBs
- Search DBs
RELATIONAL DATABASES
Regarding relational databases, two main properties determine which types of relational databases are best to use:
- Schema
- ACID
1. Schema
The schema describes how data will be structures. An example of constraints used in database creation include:
- Primary Key
- Not Null
- Foreign Key
- Int
- VARCHAR
- Default
create table EMPLOYEES {
id INT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
age INT,
department_id INT NOT NULL,
FOREIGN KEY (department_id) REFERENCES department (Id)
}
The database help design complex relations between data. Databases also prevent garbage data such as null value is not populated. As well as ensuring that all other schema constraints are being adhered to.
2. ACID
The acronym stands for:
- Atomocity
- Either a transaction is handled in its entirety or not at all
- An example of this is moving money between accounts
- Consistency
- Data is... well consistent.
- For example, if two separate read operations are run on the same data - they must not return different results.
- Isolation
- Processing of one transaction cannot depend on another, they should not know about each other.
- For example, a read of data, followed by a write to adjust the data read - does not result in another read.
- Durability
- Data needs to persist
- Highly scaleable
- Sharding
- Dynamic Data Flexibility
- Special query operations / aggregation
- Cannot guarantee that data does not include null values
- Cannot guarantee ACID properties
Search databases contain information about queries and advances indexes. Examples of search based DBs include: Elastic Search, Solar. A search database is often not the primary data store, it references the primary data story and refreshes it's data based on popular queries.
Other types of data are stored in specialist databases. Image and Videos are often stored in S3, and Bucket. Large data sets contain data from large number of users, data from IoT devices, or data captured over time.
Sometimes it's obvious which database type is the best to use in a system. Other times it's not and the type of database may need to change as common use cases from customers become clear or the type of data entering the system would be better stored in a different type of database. Some large companies even create their own database solutons.
No comments:
Post a Comment