Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Architecture & Data Abstraction
DBMS

Architecture & Data Abstraction

Master the 3-Tier architecture and the levels of data abstraction that make DBMS flexible.

Imagine a building:

  • Users only see the rooms they are allowed to enter.
  • Engineers know the building’s design.
  • Construction workers know how the building is actually built.

A DBMS works in a similar way by separating different responsibilities.


1. Database Architecture (Tiers)

Database architecture describes how users, applications, and the database communicate with each other.

1-Tier Architecture

Everything runs on the same machine.

Flow:

User

Application

Database

All three are together.

Example

  • SQLite inside a mobile app
  • MS Access database
  • Small desktop applications

Advantages

  • Very simple
  • Fast because everything is local
  • No network required

Disadvantages

  • Not suitable for many users
  • Poor security
  • Difficult to scale

2-Tier Architecture (Client-Server)

The application runs on the client, while the database runs on a database server.

Flow

Client Application

        │ Direct Connection

 Database Server

Example

  • Java application connected directly to MySQL
  • C# application connected to SQL Server

Advantages

  • Better than 1-tier
  • Data is stored centrally
  • Multiple users can connect

Disadvantages

  • Every client talks directly to the database
  • Database credentials are exposed to clients
  • Heavy load on the database server
  • Hard to scale for thousands of users

3-Tier Architecture (Most Important)

This is the architecture used by almost all modern websites and mobile apps.

Flow

User

Browser / Mobile App

Application Server

Database Server

What each layer does

1. Presentation Layer

This is what the user interacts with.

Examples:

  • Browser
  • Android app
  • iPhone app

Its job is to:

  • Display information
  • Take user input

2. Application Layer (Business Logic)

This is the “brain” of the system.

It:

  • Checks login details
  • Validates data
  • Applies business rules
  • Processes requests
  • Talks to the database

Examples:

  • Node.js
  • Spring Boot
  • Django
  • ASP.NET
  • Laravel

3. Database Layer

Stores data permanently.

Examples:

  • MySQL
  • PostgreSQL
  • Oracle
  • SQL Server

Its job is only to:

  • Store data
  • Retrieve data
  • Update data
  • Delete data

Why is 3-Tier Architecture Preferred?

Better Security

Users cannot access the database directly.

Instead,

User

App Server

Database

The application server acts like a security guard.


Better Scalability

Suppose one application server cannot handle all users.

You simply add more application servers.

Users

───────────────
│     │      │
App1 App2 App3

 Database

More users can be served without changing the database.


Easier Maintenance

If the website design changes, only the presentation layer changes.

If business rules change, only the application layer changes.

If storage changes, only the database layer changes.

The other layers continue to work.


2. Three Levels of Data Abstraction

A database stores huge amounts of data.

Not everyone needs to know how it is stored.

DBMS hides unnecessary details using three levels of abstraction.

Think of driving a car.

  • Driver → steering wheel only
  • Mechanic → engine design
  • Manufacturer → every tiny part

Similarly,

View Level

Logical Level

Physical Level

Higher levels hide the complexity of lower levels.


Level 1: Physical Level (Internal Level)

This is the lowest level.

It explains how the data is actually stored inside the computer.

Questions answered here:

  • Where is the data stored?
  • Which file contains it?
  • Which index is used?
  • Which data structure stores it?

Examples:

  • B+ Trees
  • Hashing
  • Indexes
  • Pages
  • Blocks
  • SSD
  • HDD

The user never sees these details.

Example

Instead of

Student table

the database internally stores

  • Disk blocks
  • Binary data
  • Memory pages
  • Index structures

This is the physical level.


Level 2: Logical Level (Conceptual Level)

This is the most important level.

It describes what data exists and how different data is related.

Here we define:

  • Tables
  • Columns
  • Data types
  • Primary Keys
  • Foreign Keys
  • Relationships
  • Constraints

Example

Student

StudentID
Name
Age
Department

Another table

Department

DeptID
DeptName

Relationship

Student

belongs to

Department

This level ignores storage details.

Developers mostly work at this level.


Why is the Logical Level Important?

It acts as a bridge between users and storage.

Programmers think about

  • Tables
  • Records
  • Relationships

They never think about

  • SSD blocks
  • Memory pages
  • Binary files

This makes application development much easier.


Level 3: View Level (External Level)

This is the highest level.

Different users see different parts of the same database.

The database may contain hundreds of columns, but each user only sees what they need.

Example

Database contains

Student

ID
Name
Phone
Address
Grade
Fees
Password

Student View

ID
Name
Grade

Teacher View

ID
Name
Grade
Attendance

Accountant View

ID
Name
Fees
Payment Status

Everyone accesses the same database, but each sees only the relevant information.

This improves:

  • Security
  • Privacy
  • Simplicity

Complete Picture

          View Level
      (What each user sees)


      Logical Level
 (Tables & Relationships)


      Physical Level
(Storage on Disk)

3. Data Independence

One of the biggest strengths of a DBMS is that changes at one level should not force changes at higher levels.

This property is called Data Independence.

Simply put,

Modify one layer without affecting the layer above it.

There are two types.


Physical Data Independence

Changes happen only at the physical level.

Examples:

  • HDD → SSD
  • New indexing technique
  • Data compression
  • File organization changes
  • Better storage hardware

The logical schema remains exactly the same.

Applications continue to work.

Example

Before

Student Table

Stored on HDD.

After

Student Table

Stored on SSD.

Did the application change?

No.

Users never notice the storage change.


Logical Data Independence

Changes happen at the logical level.

Examples:

  • Add a column
  • Remove a column
  • Split one table into two
  • Merge tables
  • Add new relationships

The external views should continue to work with little or no modification.

Example

Old table

Student

ID
Name
Age

New table

Student

ID
Name
Age
Email

The student view showing only

ID
Name
Age

can still work because it doesn’t depend on the new column.


Which is Harder?

Logical Data Independence is much harder.

Why?

Changing storage methods is easy to hide.

Changing the database structure often affects:

  • Queries
  • Views
  • Programs
  • Relationships

Therefore, achieving complete logical independence is much more difficult.


Interview Tip

A common interview question is:

Why do we need data abstraction?

A strong answer is:

Data abstraction hides unnecessary complexity by separating storage, database design, and user views. It improves security, simplifies development, allows multiple users to see different data, and enables changes in one layer without affecting the others.


Quick Comparison

FeaturePhysical LevelLogical LevelView Level
FocusHow data is storedWhat data is storedWhat users see
Used ByDatabase engineersDatabase designers & developersEnd users
ContainsFiles, indexes, blocksTables, keys, relationshipsSelected rows and columns
User VisibilityHiddenMostly hiddenVisible

Important Definitions

Schema

The blueprint (design) of a database.

It defines:

  • Tables
  • Columns
  • Data types
  • Constraints
  • Relationships

It changes very rarely.

Think of it as the building plan before construction.


Instance

The actual data stored in the database at a particular moment.

Example:

Morning:

IDName
1Alice

Evening:

IDName
1Alice
2Bob

The schema stayed the same, but the instance changed.


Metadata

Metadata means “data about data.”

It describes the database itself instead of the actual records.

Examples include:

  • Table names
  • Column names
  • Data types
  • Constraints
  • Indexes
  • Primary Keys
  • Foreign Keys

Example:

Student
--------
ID      INTEGER
Name    VARCHAR(100)
Age     INTEGER

These definitions are metadata—they describe the structure, not the student records.


Memory Trick

Remember the order:

View → Logical → Physical

Ask three simple questions:

  • View: What can this user see?
  • Logical: What data exists and how is it related?
  • Physical: How is the data stored?

Interview-Focused Questions

Q: Why is the Conceptual Level (Logical Level) so important?

A: It acts as a bridge. It allows programmers to focus on the structure and relationships of data without worrying about whether it’s stored on a cloud server or a local disk, and without worrying about specific user permissions.

Q: Which is harder to achieve: Physical or Logical Data Independence?

A: Logical Data Independence is much harder. While physical changes (like moving a file) are easy to hide, changing the logical structure (like splitting one table into two) often requires updating the user’s view or the application logic.

Q: Why do we use 3-tier architecture for modern web applications?

A: Primarily for Scalability and Security. The database is hidden behind an App Server, preventing direct user access. Also, you can scale the App Server (to handle more users) independently of the Database Server.

Quick Glossary

  • Schema: The skeleton/design of the database (rarely changed).
  • Instance: The actual data in the database at a specific moment (changes constantly).
  • Metadata: “Data about data” (e.g., column names, data types).

My Private Notes

Notes are auto-saved locally to this device.