One Tier, Two Tier and Three Tier Architecture
Tier architecture describes how many machines or layers a database request passes through. One tier is local, two tier puts the application on the client, three tier inserts an application server between them.
-
DBMS Fundamentals
- Data, Information and Databases
- What a DBMS Is and Why It Exists
- File System versus DBMS
- Advantages and Limitations of a DBMS
- Database Users and the Role of the DBA
- Three Level Architecture and Data Abstraction
- Logical and Physical Data Independence
- Schema, Instance and Metadata
- Database Applications and the Database System Environment
- Database Architecture
- Data Models
-
ER Model
- Entities, Entity Sets and Entity Types
- Types of Attributes in the ER Model
- Keys in the ER Model
- Relationships, Relationship Sets and Degree
- Cardinality and Participation Constraints
- Strong and Weak Entities
- Drawing and Reading ER Diagrams
- Extended ER: Generalisation, Specialisation and Aggregation
- Converting an ER Diagram into Relational Tables
- ER Design Projects
- Relational Model
- Relational Algebra
- Functional Dependencies
-
Normalisation
- Why Normalisation Exists: Anomalies and Redundancy
- First Normal Form
- Second Normal Form and Partial Dependency
- Third Normal Form and Transitive Dependency
- BCNF and BCNF Decomposition
- 4NF, 5NF, Multivalued and Join Dependencies
- Lossless Decomposition and Dependency Preservation
- Complete Worked Normalisation: Unnormalised to BCNF
- Denormalisation and When to Use It
Concept
Tier architecture counts the layers a request crosses between the user and the stored data. It is a deployment question, and it is entirely different from the three level architecture of Phase 1.
Three level architecture is about abstraction — external, conceptual, internal. Three tier architecture is about deployment — client, application server, database server. Examiners set this trap every year.
One tier architecture
+----------------------------+
| user + application + DBMS |
| all on the same machine |
+----------------------------+The user sits directly at the machine holding the database. There is no network in the path. Used for local development, embedded databases inside a single application, and small single user tools.
- Advantages — simplest possible setup, fastest for one user, no network failure.
- Disadvantages — no sharing, no remote access, security is only as good as the machine, does not scale beyond one user.
Two tier architecture
CLIENT machine SERVER machine
+-----------------------+ +---------------+
| application logic | network | DBMS |
| user interface |<=======>| database |
| database driver | | |
+-----------------------+ +---------------+
Each client opens its OWN connection to the database.The application runs on the client and talks directly to the database server. This is the classic client server database application.
- Advantages — straightforward, fewer moving parts than three tier, direct and therefore low latency.
- Disadvantages — every client needs database credentials and a driver, business logic is duplicated on every client, updating the application means updating every machine, and the connection count grows with the number of clients.
Three tier architecture
PRESENTATION APPLICATION DATA
+-----------+ +--------------+ +-----------+
| browser |<====>| app server |<===>| DBMS |
| or thin | | business | | database |
| client | | logic, | | |
+-----------+ | connection | +-----------+
| pool, auth |
+--------------+
The client NEVER talks to the database directly.An application server sits in the middle. It holds the business logic, authenticates users, and owns a small pool of database connections shared by thousands of clients.
- Advantages — the client needs no database credentials, logic is changed in one place, connection pooling means far fewer database connections, each tier scales independently, and the database can sit in a private network unreachable from outside.
- Disadvantages — more components to build, deploy and monitor; one extra network hop; the application server becomes a failure point unless it is made redundant.
Comparison
| Point | One tier | Two tier | Three tier |
|---|---|---|---|
| Layers | 1 | 2 | 3 |
| Where the logic lives | Same machine | On the client | On the application server |
| Client holds DB credentials | Not applicable | Yes — a real weakness | No |
| Database connections | One | One per client | A shared pool |
| Updating the application | One machine | Every client | The server only |
| Scalability | None | Limited | Good |
| Security | Local only | Weak — database exposed to clients | Strong — database can be private |
| Typical use | Local tools, embedded databases | Internal desktop applications | Web and mobile applications |
Example
The same college results system, three ways
ONE TIER a lecturer keeps marks in a local database on a
laptop. Nobody else can see them.
TWO TIER a desktop program is installed in twelve offices.
Each copy holds a database username and password.
A rule change means visiting twelve machines, and
anyone who opens the program config sees the
credentials.
THREE TIER a web portal. Students use a browser. The
application server checks who they are, applies
the rules once, and uses eight pooled connections
to serve four thousand students. The database
accepts connections only from the app server.Where n tier goes next
Beyond three tiers the same idea repeats: a load balancer in front, a caching tier, a reporting replica, a message queue for slow work. The principle never changes — separate responsibilities so each can be secured, scaled and changed on its own.
Common mistakes
- Confusing tier with level. Levels are abstraction (external, conceptual, internal). Tiers are deployment.
- Calling the browser and the server two tiers of a web application. A web application with server side logic and a separate database is three tier; the browser is the presentation tier.
- Saying three tier is always better. For a single user embedded tool it is pure overhead.
- Forgetting the security argument. The strongest case for three tier is that the client never holds database credentials.
Exam and interview questions
- Draw and explain one tier, two tier and three tier architecture.
- Differentiate three tier architecture from the three level architecture.
- Give two advantages and two disadvantages of two tier architecture.
- Why does three tier scale better than two tier? Answer in terms of connections.
- In which architecture does the client hold database credentials, and why is that a problem?
Practice
- Classify each as one, two or three tier: a mobile banking app, a spreadsheet with an embedded database, a hospital desktop program connecting straight to a server, a public web store.
- A two tier system has 500 clients each holding one connection. Explain what three tier changes, with numbers.
- List three things that must be made redundant before an application server stops being a single point of failure.
Conclusion
One tier keeps everything on one machine, two tier puts logic on the client and exposes the database to it, and three tier inserts an application server that holds the logic, pools the connections and lets the database hide behind it.