Checking your session…
Module 02: Introduction to Databases and SQL

2.1 Multi-Tier Architecture

Level: 2 | Version: v1.1 | Author: Meptrasoft

Overview

Most modern applications are built by dividing the system into separate tiers, with each tier responsible for a specific job.

A common design is Three-Tier Architecture:

TEXT
CLIENT TIER
     ↓
APPLICATION TIER
     ↓
DATABASE TIER

This separation makes applications easier to develop, secure, maintain, and scale.

Three-Tier Application Architecture: Client Tier, Application Tier, and Database Tier
Figure 1: Three-tier architecture separates the user interface, application logic, and database into different tiers.

Client Tier

The Client Tier is the part of the application that the user sees and interacts with.

It is also called the presentation layer.

Examples include:

  • Web browser
  • Mobile application
  • Desktop application

For example, when you open an online shopping website, the product page, search box, buttons, and forms belong to the client side.

TEXT
USER
  ↓
CLIENT TIER
  ↓
Displays information
and collects user input

Application Tier

The Application Tier contains the application's processing and business logic.

It receives requests from the client, performs required processing, applies business rules, and communicates with the database when necessary.

For example, when a customer logs into an online banking application, the application tier can:

  • Validate the login request
  • Apply business rules
  • Query customer information
  • Prepare the response
TEXT
CLIENT REQUEST
       ↓
APPLICATION TIER
       ↓
BUSINESS LOGIC
       ↓
DATABASE REQUEST

Examples of technologies that can be used in this tier include:

  • Python
  • Java
  • C#
  • Node.js
  • .NET

Database Tier

The Database Tier is responsible for storing and managing application data.

It typically contains the database server or database system.

Examples:

  • MySQL
  • PostgreSQL
  • SQL Server
  • Oracle

For example, an online banking database may store:

TEXT
Customers
Accounts
Transactions
Payments

The application tier sends database requests and receives the required results.

The database tier stores and manages data; the application tier decides how that data is used by the application.


How the Tiers Communicate

Consider an online shopping application.

When a user searches for a product:

TEXT
USER
 ↓
CLIENT
 ↓
APPLICATION
 ↓
DATABASE
 ↓
APPLICATION
 ↓
CLIENT
 ↓
USER

For example:

  1. The user searches for “Laptop”.
  2. The client sends the request to the application.
  3. The application processes the request.
  4. The application sends a database query.
  5. The database returns matching records.
  6. The application prepares the response.
  7. The client displays the products.

The client normally does not connect directly to the database.

Important Note

The application tier communicates with the database using a database connection, driver, or database protocol. An API is normally used for communication between the client and application/service layer.


Why Use Three Tiers?

Separating the application into tiers provides several benefits.

Security

The database does not need to be directly exposed to users or public clients.

Maintainability

Changes to the user interface can often be made without changing database logic.

Scalability

Different tiers can be scaled independently when application traffic increases.

Business Logic Isolation

Business rules remain in the application tier instead of being placed entirely inside the client.

Connection Management

The application tier can manage database connections efficiently, including techniques such as connection pooling.


One-Tier, Two-Tier, and Three-Tier Architecture

The idea becomes clearer when we compare the common architectures.

1-Tier Architecture

All major components run together on the same machine.

TEXT
CLIENT
+
APPLICATION
+
DATABASE

       ↓

SAME MACHINE

Example:

A desktop application using a local SQLite database.

2-Tier Architecture

The client communicates directly with the database server.

TEXT
CLIENT
   ↓
DATABASE SERVER

This is commonly called client-server architecture.

3-Tier Architecture

An application tier is placed between the client and database.

TEXT
CLIENT
   ↓
APPLICATION
   ↓
DATABASE

This is common in web applications.

Simple Comparison

Architecture Basic Structure Typical Example
1-Tier Client + Logic + Database Local desktop app with SQLite
2-Tier Client → Database Desktop client connected to database server
3-Tier Client → Application → Database Web or mobile application

Real-World Example: Online Banking

Consider an online banking application.

Client Tier

The customer uses:

TEXT
Web Browser / Mobile App

to enter:

TEXT
Username
Password
Transfer Amount

Application Tier

The application:

  • Authenticates the user
  • Validates the transfer
  • Applies business rules
  • Sends database requests

Database Tier

The database stores:

TEXT
Customer Details
Account Details
Transaction Details

The complete flow is:

TEXT
Customer
   ↓
Banking App
   ↓
Application Server
   ↓
Database
   ↓
Application Server
   ↓
Banking App
   ↓
Customer
Three-Tier Request and Response Flow: Login and Account Balance example across Client, Application, and Database tiers
Figure 2: In a three-tier application, the client sends requests to the application tier, which communicates with the database and returns the result.

Common Beginner Mistakes

✗ Mistake ✓ Correct Understanding
Client means only a physical computer A client can be a browser, mobile app, or desktop application
The database is the application The database stores and manages data; the application contains processing logic
The client should directly connect to the database in a web application The application tier normally sits between the client and database
API always connects the application to the database APIs commonly expose application/service functionality; database communication normally uses database drivers/connections/protocols
Three-tier means three physical computers Tiers are logical layers; they may or may not run on separate physical or virtual machines
Three-tier architecture is required for every application Simpler applications may use one-tier or two-tier designs

Placement Quick Points

TEXT
1-TIER
→ CLIENT + APPLICATION + DATABASE

2-TIER
→ CLIENT → DATABASE

3-TIER
→ CLIENT → APPLICATION → DATABASE
  • Client Tier → user interface and user interaction.
  • Application Tier → processing and business logic.
  • Database Tier → data storage and management.
  • Three-tier architecture separates responsibilities between layers.
  • The client normally communicates with the application tier rather than directly with the database.
  • The application tier communicates with the database through database connections, drivers, or protocols.
  • Three-tier architecture can improve security, maintainability, and scalability.

Interview Questions

What is multi-tier architecture?

Multi-tier architecture divides an application into separate logical layers, with each layer responsible for a specific function.

What are the three tiers in three-tier architecture?

They are:

TEXT
Client Tier
Application Tier
Database Tier
What is the role of the Client Tier?

It provides the user interface and allows users to interact with the application.

What is the role of the Application Tier?

It handles application processing, business rules, validation, and communication between the client and database.

What is the role of the Database Tier?

It stores and manages application data.

What is the difference between two-tier and three-tier architecture?

In two-tier architecture, the client communicates directly with the database.

In three-tier architecture, the application tier is placed between the client and database.

TEXT
2-TIER
Client → Database

3-TIER Client → Application → Database

Why is three-tier architecture preferred for many web applications?

It separates the user interface, business logic, and database access. This can improve security, maintainability, and scalability.

Give an example of a one-tier application.

A local desktop application that stores its data in an embedded SQLite database on the same machine is an example of a one-tier design.

Does each tier need to run on a separate machine?

No. Tiers are logical layers. They can be deployed on the same machine or on separate servers depending on the application's requirements.


Practice & Hands-On Exercises

Beginner Practice

  1. What is multi-tier architecture?
  2. Name the three tiers in a three-tier architecture.
  3. What does the Client Tier do?
  4. What does the Application Tier do?
  5. What does the Database Tier do?

Think and Answer

  1. Explain the difference between 2-tier and 3-tier architecture.
  2. Why should a web application usually avoid giving users direct database access?
  3. What would happen if the application tier did not exist?
  4. Does three-tier architecture always require three physical servers? Explain.

Real-World Practice

  1. Draw the three-tier architecture of an online banking application.
  2. Trace what happens when a user logs in.
  3. Identify the tier responsible for each task:
  • Displaying a login form
  • Checking business rules
  • Storing customer details
  • Querying account information

Key Takeaway

TEXT
USER
  ↓
CLIENT TIER
  ↓
APPLICATION TIER
  ↓
DATABASE TIER
  ↓
DATA

Three-tier architecture separates the user interface, application logic, and data management into different logical layers.

End of Multi-Tier Architecture