Quick revision
The short answer
The swings follow cost and constraints: in client-server systems the database was the one shared, powerful server, so logic lived there; application servers and cheap horizontal scaling then pulled logic out; today managed databases and data platforms make SQL attractive again. Each move fixed a real problem, such as round trips, scaling, testing or lock-in, and created a new one. A large company should decide by workload, keep portable assets like standard SQL and constraints, avoid proprietary code where an exit matters, keep skills in both SQL and application design, and record why each decision was made.
What to remember
In this answer, we saw that logic moved into the database when it was the one shared, powerful server, moved out when application servers scaled cheaply and testing practices matured, and is moving partly back because managed databases and data platforms make SQL near the data efficient again. Each move solved a real problem and created another. A large company should decide by workload, keep portable assets like standard SQL and constraints, accept proprietary lock-in only knowingly, keep both SQL and application skills, and record why each choice was made.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The swings follow cost and constraints: in client-server systems the database was the one shared, powerful server, so logic lived there; application servers and cheap horizontal scaling then pulled logic out; today managed databases and data platforms make SQL attractive again. Each move fixed a real problem, such as round trips, scaling, testing or lock-in, and created a new one. A large company should decide by workload, keep portable assets like standard SQL and constraints, avoid proprietary code where an exit matters, keep skills in both SQL and application design, and record why each decision was made.
Background to this question
Senior architects are expected to have seen at least one full swing of this pendulum and to explain it without nostalgia or fashion. The question is really about how technology decisions are made: what economic and technical pressures pushed logic from one tier to another, and how to avoid paying for the same migration twice. In this answer, we will walk through the three eras and what drove each, look at the problems each move solved and created, and then turn that history into a planning approach for a large company.
1The Client-Server Era: Logic Near the Shared Server
In the late 1980s and 1990s, a typical business system was a desktop client talking directly to a database server over a slow local network. The clients were weak and hard to update, because every change meant reinstalling software on hundreds of machines. The database server was the one powerful, centrally managed machine.
So putting logic into stored procedures made sense. One procedure call replaced dozens of round trips over the slow network, a fix to a procedure reached every client at once, and the DBA team controlled the shared resource. Vendors encouraged it with rich procedural languages such as PL/SQL and T-SQL, which also made moving away from that vendor expensive.
2The Application Server Era: Logic Moves Out
Web applications and three-tier architectures changed the constraints. Clients became browsers, so the update problem disappeared. Application servers, and later commodity Linux machines in a cloud, could be added cheaply, while the database remained a single expensive machine that was hard to scale. Spending its CPU on business logic was now the costly choice.
At the same time, engineering practice moved towards automated testing, continuous delivery and object-oriented domain models. Logic in Java could be unit tested in milliseconds, versioned with the code and deployed many times a day; logic in stored procedures needed a database, a DBA and a coordinated release. ORMs such as Hibernate made the database look like storage. The cost of this move appeared slowly: chatty data access with many round trips, N+1 queries, and teams that forgot how to write good SQL.
3The Current Swing: SQL Becomes Attractive Again
Several forces pull logic back towards the data today. Managed databases remove much of the operational pain that once came with database code. Cloud data warehouses and lakehouses scale SQL across many machines, and tools that manage SQL transformations as versioned, tested code have made SQL feel like software engineering again. Some platforms offer serverless functions that run inside or next to the database, and data volumes have grown so much that moving data to the code is often more expensive than moving code to the data.
So analytics and data transformations increasingly live in SQL, and some teams push transactional logic into database functions to save network hops. The new costs are familiar ones: proprietary dialects and functions that tie us to one vendor, pricing by compute or by query that is hard to predict, and logic spread across tools that a service team cannot see.
| Era | Driver | Solved | Created |
|---|---|---|---|
| client-server, stored procedures | weak clients, slow LAN | round trips, central updates | vendor lock-in, hard testing |
| application servers, ORMs | cheap horizontal scale | testability, fast delivery | chatty access, weak SQL skills |
| managed DBs, data platforms | huge data, managed ops | data movement, ops burden | new lock-in, usage-based cost |
4Planning for Portability Where It Matters
A company cannot avoid every dependency, but it can choose where it accepts lock-in. Standard SQL, declarative constraints and a well-designed schema are cheap to move between databases. Large amounts of procedural code in a proprietary language are not: a migration from one vendor to another can mean rewriting thousands of procedures. So the plan should state, per system, how likely an exit is and how costly lock-in would be, and allow proprietary features where the benefit is high and an exit is unlikely.
Portability is not only about the database vendor. Keeping business rules in one clearly owned place, whichever tier it is, makes any future move cheaper, because we know what to move.
5Deciding by Workload, Not by Fashion
The most useful planning rule is that different workloads have different best places, so the company should not make one decision for all of them. Transactional business rules, which change often and need tests and integration with other services, belong in services, with integrity enforced by constraints. Data-heavy transformations, such as building a daily ledger from millions of events, belong close to the data in set-based SQL, managed as versioned code. Analytics belongs in an analytical platform built for scans and aggregation, fed from the transactional systems rather than run on them.
- Is it an integrity rule on stored data?keys, uniqueness, valid valuesYesConstraint in the operational databaseNoNext question
- Is it a transactional business rule?changes often, calls servicesYesService code, tested and versionedNoNext question
- Is it a bulk transformation over large data?YesSet-based SQL near the data, as versioned codeNoAnalytical platform for reporting
3 steps in order. Play them, or step through them one at a time.
6Keeping Skills and Recording Decisions
The swings hurt most when a company loses a skill. Teams that grew up with ORMs often cannot read a query plan, and teams of database specialists may not know modern testing. A large company should keep both: SQL and data modelling training for application engineers, software practices such as version control and automated tests for data engineers, and people who move between the two.
Finally, decisions should be written down as short architecture decision records that state the context, the options and why we chose one. In ten years the constraints will change again, and the next generation of engineers should be able to see whether the original reasons still hold, instead of reversing a decision because it looks old-fashioned.
7Follow-up questions
Is moving logic back into the database a mistake, then?
Not in itself. It is a mistake when it is done as a fashion for all logic. For data-heavy work it is often the right answer today, as it was for round trips in the 1990s. The question is always which workload, which costs and which exit path.
How do you measure lock-in?
We estimate the cost of leaving: how many procedures, proprietary functions or platform features we would have to rewrite, how much data must move, and how long it would take. Putting a rough number of engineer-months next to each system makes the risk discussable instead of emotional.
What would you tell a team that wants to use serverless database functions?
Use them where they remove real network hops or data movement, treat them as code with version control, tests and review, check their pricing at our volume, and keep the business rules that change often in the service so the team can still release them quickly.
8Conclusion
In this answer, we saw that logic moved into the database when it was the one shared, powerful server, moved out when application servers scaled cheaply and testing practices matured, and is moving partly back because managed databases and data platforms make SQL near the data efficient again. Each move solved a real problem and created another. A large company should decide by workload, keep portable assets like standard SQL and constraints, accept proprietary lock-in only knowingly, keep both SQL and application skills, and record why each choice was made.
Open with
I see these swings as rational responses to changing costs. In client-server systems the clients were weak and the network slow, and the database was the one powerful, centrally managed server, so stored procedures saved round trips and let a fix reach every client at once, at the price of vendor lock-in and logic that was hard to test.
Then, if they want more
Then web applications and cheap horizontal scaling made application servers the cheap tier and the database the expensive bottleneck, while automated testing and continuous delivery made Java the easier place to change logic. That move gave us testability and speed, but also chatty data access and teams that lost their SQL skills.
Today managed databases, scalable data platforms and huge data volumes make it cheaper to move code to the data, so SQL is attractive again, with new lock-in and usage-based costs.
For a large company I would plan by workload instead of picking a side: transactional business rules in services with integrity in constraints, data-heavy transformations in set-based SQL near the data as versioned code, and analytics on an analytical platform. I would accept proprietary features knowingly where an exit is unlikely and prefer standard SQL elsewhere.
And I would keep both skill sets alive and record decisions with their reasons, so the next team can tell whether those reasons still hold.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Thirty years ago much business logic lived in stored procedures; then it moved to...": https://scrivio-interview-library.netlify.app/databases/stored-code/da2eac2bf7/