What is a Database?

A database is an organized collection of data that allows us to store, retrieve, update, and delete information efficiently.

Real-world Example

Imagine you're managing a college.

Without a database, you might store student details in notebooks or Excel files.

Student 1
Name: Rahul
Age: 20
Branch: CS

Student 2
Name: Priya
Age: 21
Branch: IT

Now imagine 10 lakh students.

Finding one student's information manually becomes slow and difficult.

A database organizes this information so you can quickly find, update, or delete records.


What is DBMS?

DBMS (Database Management System) is software that helps users and applications interact with a database.

Think of it as the middleman between your application and the stored data.

User
   |
   v
Application
   |
   v
 DBMS
   |
   v
Database

The application never directly manipulates the files where data is stored. It communicates with the DBMS.

Examples of DBMS:


Why do we need a DBMS?

Without a DBMS, an application would have to manage everything itself:

That's a huge amount of work.

A DBMS provides these features out of the box.

Responsibilities of a DBMS


Database vs DBMS

Database DBMS
Collection of data Software that manages the data
Stores information Performs operations on the data
Passive Active
Example: Student records Example: MySQL, PostgreSQL

Think of it like this:

The books contain the information.

The librarian helps you find, update, organize, and protect the books.


Types of Databases

For interviews, you mainly need to know two categories.

1. Relational Database (RDBMS)

Stores data in tables.

Users Table

ID Name Age
1 Rahul 22
2 Priya 24

Orders Table

Order ID User ID Amount
101 1 500
102 2 700

The User ID links the two tables.

Characteristics:

Examples:


2. NoSQL Database

Doesn't require data to be stored in tables.

Instead, data can be stored as:

Example document:

{
  "id": 1,
  "name": "Rahul",
  "age": 22,
  "skills": ["Java", "Spring", "React"]
}

Examples:

We'll cover NoSQL in detail later.


RDBMS vs NoSQL

RDBMS NoSQL
Tables Documents / Key-Value / Graph / Column
Fixed schema Flexible schema
SQL Database-specific APIs or query languages
Strong relationships Fewer or no enforced relationships
ACID transactions Often optimized for scalability and flexible consistency models
Best for structured data Best for rapidly changing or unstructured data

Where is DBMS used?

Almost every backend application uses one.

Examples:

Whenever an application needs to persist data, a database is usually involved.


Interview Questions

1. What is a database?

A database is an organized collection of data that enables efficient storage, retrieval, updating, and deletion of information.

2. What is a DBMS?

A DBMS is software that manages databases and provides services like data storage, querying, security, concurrency control, backup, and recovery.

3. What is the difference between a database and a DBMS?

A database is the stored data itself, while a DBMS is the software used to create, manage, and access that data.

4. Give examples of DBMS.

5. Why do we use a DBMS instead of files?

Because a DBMS provides efficient querying, security, concurrency control, consistency, backup and recovery, and reduces the complexity of managing data manually.


Key Takeaways