Part 5 of 5 · 4 min read
Exercises
Easy
Easy 1: Name the tiers (15 minutes)
A mobile app calls a backend API, which is the only thing that talks to the database. Name each tier and what runs in it.
Done when: all three tiers are named with what runs in each.
Hint
The mobile app is the client tier, the backend API is the application tier, and the database is the data tier.
Easy 2: Spot the 2-tier system (15 minutes)
A spreadsheet macro connects directly to a shared database file using stored credentials inside the macro. State whether this is 2-tier or 3-tier, and why.
Done when: 2-tier is correctly identified, with the direct connection named as the reason.
Hint
The macro connects directly, with no server in between, so this is 2-tier.
Easy 3: One rule, one place (15 minutes)
State which tier should hold the rule "a discount cannot exceed 50 percent" in a 3-tier bookstore system, and why that tier and not another.
Done when: the application tier is named, with a reason tied to having one place to change the rule.
Hint
Keeping the rule in the application tier means it changes in one place, not in every client.
Medium
Medium 1: Convert 2-tier to 3-tier (25 minutes)
The desktop bookstore application from part 1 is being redesigned as 3-tier. Describe what moves out of the client, what the client keeps, and what the new middle tier takes on.
Done when: the business logic and database credentials are correctly moved out of the client and into the new application tier.
Hint
Move the discount check and the database connection into the new server; the client keeps only the user interface and calls to the new server's API.
Medium 2: Scaling tiers independently (25 minutes)
The bookstore website gets 10 times more traffic during a holiday sale. Explain what can be scaled in a 3-tier system to handle this, and what likely cannot be scaled the same way.
Done when: the application tier is identified as easy to scale by adding servers, and the database is identified as harder to scale the same way.
Hint
More application servers can be added behind a load balancer; the database often needs a different kind of scaling, covered in later levels.
Medium 3: Tiers versus three-schema levels (25 minutes)
Explain in two or three sentences why a 3-tier system's database still has its own internal, conceptual and external levels, independent of the application tier sitting above it.
Done when: the explanation correctly separates "how many tiers this system has" from "how this database organizes its own data."
Hint
Tiers describe the system's layers; the three-schema levels describe how one of those layers, the database, organizes data inside itself.
Hard
Hard 1: A security argument for 3-tier (30 minutes)
Explain, using a concrete scenario, why storing database credentials inside a client application (as in 2-tier) is a bigger security risk than storing them only inside an application server.
Done when: a concrete scenario is given where a leaked client, but not a leaked application server, exposes the credentials to many more people.
Hint
A leaked mobile app or desktop installer can expose credentials to every person who downloads it, while a leaked application server exposes credentials to a much smaller, controlled set of operators.
Hard 2: When 2-tier is still the right choice (35 minutes)
Describe a realistic situation where a 2-tier architecture is actually the better choice over 3-tier, and explain why adding a middle tier there would be unnecessary overhead.
Done when: a concrete situation is given, such as a single-user desktop tool, with a reason the extra tier adds no value there.
Hint
A single-user offline tool with no other clients gains nothing from a middle tier, since there is no logic to share across multiple clients.
Hard 3: Design a 4-tier system (40 minutes)
The bookstore adds a caching layer between the application server and the database to reduce load on repeated reads. Draw the resulting 4-tier system, and state which tier is now responsible for keeping cached data from going stale.
Done when: all four tiers are named in order, and the staleness responsibility is assigned to a specific tier.
Hint
Client, application server, cache, database; the cache tier, or the application server managing it, is responsible for invalidating stale entries.