Skip to main content

Command Palette

Search for a command to run...

Database Management System

Updated
2 min read

A database is a collection of related data, stored electronically and managed in a way that makes it easy to store, retrieve, modify, and organize. Databases are typically managed by a Database Management System (DBMS). These systems organize data either in the form of tables or objects so that it can be easily accessed by the users or applications. Broadly, we have relational and non-relational databases.

Relational Databases

Relational databases store data in tables, where rows represent the actual data and columns represent attributes. Because of this tabular structure, these databases allow relationships between tables using joins, which help maintain data integrity. Relational databases follow a predefined and strict schema, so changing a field or adding a new column can become an expensive operation, especially when the table grows large or has many dependencies. Examples include MySQL, PostgreSQL, and SQL Server.

ACID Properties:

  1. Atomicity: All or nothing

  2. Consistency: Transactions leads database from one valid state to another.

  3. Isolation: Concurrent transactions don't interfere.

  4. Durability: Committed data is permanent

Non-Relational Databases

Non-relational databases are more flexible with schema, meaning you can change the structure of data without affecting the previously stored data. Many non-relational systems focus on availability and scalability, and some follow eventual consistency, where the database may return stale data for a short time rather than returning no data at all. Non-relational databases do not support joins in the same way relational ones do, so maintaining references has to be done manually. This can lead to issues like dangling references if a linked document or key gets deleted. Examples include MongoDB, Cassandra, Redis, and DynamoDB.

BASE Properties:

  1. Basically Available

  2. Soft State

  3. Eventually change

Many large-scale applications now use a hybrid approach, leveraging ACID for critical data (like user accounts) and BASE for high-volume, less critical data (like likes/feeds) to get the best of both worlds.