Skip to main content

Command Palette

Search for a command to run...

Databases

Updated
5 min readView as Markdown
Databases
N

Neha Chopra | Finance Writer → Full-Stack Developer in Progress I write finance case studies and analytical articles, and I’m currently transitioning into web development. Passionate about building clean, functional web experiences while bringing an analytical mindset from finance into tech.

When we store data on a computer, it’s tempting to imagine that the disk neatly arranges files in folders, tables in rows, records in order.

But that’s just an illusion.

A Disk, which stores data in bytes, is fundamentally dumb. It doesn’t understand structure, meaning, or relationships. It simply stores raw bytes, streams of binary data (0s and 1s). Whether those bytes represent a database table, an image, or random noise is completely irrelevant to the disk.

It is the high level systems present on top of disk called databases that give meaning to raw bytes stored on disk. They interpret the bytes stored on disk and organize them into meaningful forms like tables and records. A Databases knows

  • Where data is located

  • How different pieces of data relate to each other

  • And how to retrieve exactly what’s needed—often in milliseconds

In essence, while the disk is just a warehouse of unlabeled boxes, the database is the warehouse manager, labeling and organizing the boxes so that ****the required box could be found quickly and reliably.


Databases

There are multiple ways in which databases can organize data. They could store data in form of tables or in the form of lists.

Based on how do they organize, databases can be categorized as

  • Relational databases (SQL)

  • Non-relational databases (NoSQL)


Relational databases

Relational databases organize the data into tables made up of columns and rows much like spreadsheets in excel.

Lets say you want to build an e-commerce app. Using relational databases, we could create multiple tables with each table containing related data. Like a table that contains details relating to users like email and name.

|   id    | name  | email                                  |
| ------- | ----- | ---------------------------------------|
| 1       | Neha  | [neha@mail.com](mailto:neha@mail.com)  |
| 2       | Rahul | [rahul@mail.com](mailto:rahul@mail.com)|

There could be instances where data of one table be used in another table. Orders table might want users data stored in users table to recognize whose order is being stored. We could use the concept of keys here. We could assign an id for every row of users table (primary key) and reference the key belonging to the user who ordered, in the orders table (Foreign key).

Orders data -

| id (PK) | user_id (FK) | product | amount |
| ------- | ------------ | ------- | ------ |
| 101     | 1            | Shoes   | 2000   |
| 102     | 2            | T-shirt | 800    |
| 103     | 1            | Watch   | 5000   |

This ability to connect one table with another is what makes relational databases powerful. Because the data in a table follows specific structure, relational databases guarantee consistency.

Use cases

Relational databases can be used when -

  1. The data used in application is highly interconnected.

  2. The data follows a clear pattern.

  3. The correctness and consistency of data is priority.

PostgreSQL, MySQL and SQLite are some of the relational databases.


Non-relational databases

Like a folder that may contain files ranging from a text file to a code file to a video file, non relational databases store data as a document or as key-value pairs, inside collections without forcing every document to follow strict structure.

{
  "name": "Neha",
  "phone": "9876543210"
}
{
  "name": "Rahul",
  "email": "rahul@mail.com",
  "last_login": "2026-04-08"
}

Notice both documents belong to same collection yet they have different fields. Documents in a collection are independent of each other. Data in one is not dependent or connected to data in another.

This lack of a rigid structure makes non-relational databases highly flexible and adaptable. As your application evolves, your data might evolve and this evolved data can be easily be stored without any restructuring.

Use cases

Non relational databases can be used

  1. Where data keeps evolving and scalability is priority.

  2. Fast read and write operations need to be performed with minimal constraints.

MongoDB and Cassandra are some of the non-relational databases.


Relational vs Non-relational databases

Basis Relational Database Non - relational database
How is data organized? Tables with rows and columns Collection of key value pairs and documents
Data structure Fixed Flexible
Connections and relationships We can establish connections between 2 tables using keys Establishing connection is generally avoided since the structure of data might differ for every document.
Scalability Since rows are easier to add, it promotes vertical scaling Since no rigid structure is followed , newer key value pairs can be easily added and promotes horizontal scaling.
Use cases in real life Banking, Accounting and billing softwares. Real time apps, caching

Since both the systems have their own advantages and downsides, many production systems use both. A relational database for transactional and consistent data like data pertaining to user or orders. A non relational database for fast moving and varying data like logs and caching data.

Conclusion

The disk is the body. The database is the mind. Without a database, your hard drive is just a very expensive pile of ones and zeros. With one, those same bits can answer questions, enforce rules, model complex relationships, and scale to serve millions of users.