Perks
- It’s all in one place. It’s easier to maintain.
- Can performance gains. Software is optimized for this.
- Serves many applications using various technologies and languages without problems. Even allows direct access.
- Facilitates application developments by not having to deal with this logic.
- Allows more effective and granular access control to the bank.
Database is great at storing and retrieving information in various ways. When you want to do much more than that, you are using the wrong tool. Database is a mechanism, and he’s great at it. He doesn’t work very well trying to provide abstractions. When the mechanism is most important, you do it on.
There is application for everything. When the database is more important than the application, it is possible to make the logic work better inside the DB. A Data Warehouse, for example, benefits from this. If the database defines the solution well and the applications running on it are just satellites. If, in a way, the database becomes the application, it makes sense to use more of its resources.
Business rules and data rules are different things. Data rules fit well inside the database, always.
I know of other items that seem like advantages, but that there is a solution as good or better putting logic in the application. Just need to understand how. I will not put as an advantage things that are only advantages if it is done the right way and when you do it the right way in the application layer, there is also advantageous. For example, if you know what you’re doing in DB or the application, the data can be consistent. If you do not know, you will have problems doing in any of them. That’s why using what you (or your team) know is more important than how to do it. The response of Gypsy Morrison Mendez shows this. The first advantage he cites is only real if there are no other problems, especially, but not only, those mentioned by him in the first and third items of the disadvantages.
Disadvantages
- Virtually requires a DBA to optimize the database.
- Developers will need to know the language of the database well. It is rare to find professionals with knowledge and experience beyond the trivial. It is easy to find those who think they have both.
- SQL, even amplified, is not very expressive. It is usually less productive to program in any available variation. The codes are ugly and disorganized.
- Programmers don’t understand how to make database interfaces for applications properly.
- The database receives an extra workload that can precipitate the need for scheduling. And it is more difficult to scale the DB than the application.
- You get stuck with the database provider or work hard to replicate the logic to other vendors, losing the first advantage item.
- Applications depend on the database to be able to do various maintenance.
- It is illusion to think that you can put all logic in DB, so in practice you end up with a hybrid solution.
- Versioning is much more complicated.
- Tests are more complicated.
- Debugging is more complicated.
- Documentation is not so simple.
- Keeping development timing between the team is tricky.
- There are no such good tools to handle DB code.
- Makes code reuse difficult. Creates excessive coupling.
- A change in a field can generate a huge amount of cascade changes in other parts of the bank.
- Programmers hate this (opinion, ok, but this should be considered).
There are several ways to put logic into the application. Using a ORM is just one of them. The use of ORM often ends up being justification to put logic in DB, after all it is common for Orms to be complex and inflexible.
An application can do most of the business logic and leave to the bank what it can do better than the application. Beware of premature optimization. In a database this can produce contrary results more easily. If you choose to put business rules only as optimization you may be creating another disadvantage.
If an application only uses the database as a mechanism for storing data and it is it that is important in the solution, it is clear that putting more than is needed in DB is bad.
My experience
Particularly I use logic in the application, it suits me well, it comes cheaper for me. I work with software that are products. So:
- I need to have more control over the application.
- I need to support various database providers.
- I know that my application will be the only one to access the DB. I provide an API on an application server for other applications to access DB indirectly.
- I need to get rid of all the disadvantages that this brings more than the advantages it provides.
- The entire application, including database modeling, is mine and not the client’s, only the data is his.
- There is an established culture. It’s important to make decisions. It’s not just the technical that counts. Better use what you have expertise than to venture into something great that you don’t master. Unless the advantage is brutal.
Why am I saying this? So you can understand my situation and judge if I’m being biased. The advantages described exist even and it is difficult who can list advantages genuinely different from those presented, they can be detailed or specified better, but it is difficult to find something different.
Your case
First I tell you to enjoy the experience. Try to keep an open mind and try to learn a way to develop that you are not used to. Trying to change the course of what has already been decided will probably only bring you problems and will waste an opportunity to develop better.
Try using some of the items you are reading in the answers here to try to assess whether everything is correct in the project. But note that each project is different. Not all advantages and disadvantages will be found in all projects.
It would be terrible if you were in charge of the project and were doing something you don’t know.
The biggest question I could ask is: why will the project be centered on DB? If the decision was made with appropriate criteria, if it was thought, if it was taken into account all the points that could bring advantages or disadvantages, it is probably on the right track.
Is the project just an internal system? What is the background team? How will the evolution of this solution?
Good practice is to do the right thing in every situation, you will find out if it is the case in this project over time.
Completion
Basically if you ask a programmer (really) he will say that it is better to put in the application. If ask for the DBA (even the one that also program), it will say that it is better to put in DB. Most of the time the decision is made based on previous experiences or preconceived ideas of what is ideal. You choose which problems you want to deal with. It may seem that this is bad, but not necessarily. Surprisingly people decide without even knowing why.
Common sense and experience always count for more than any generic recommendation. The problem is that everyone has their own common sense and experience is influenced by several factors.
I put in the Github for future reference.
Another user asked a related question today that might be interesting to you: http://answall.com/questions/15702/e-realmente-necessario-definir-constraints-no-banco-data#comment28468_15702
– Oralista de Sistemas
I think it depends a lot on what to do, may or may not be advantageous... I think it gets a little in the opinion and sensitivity of each.
– Jorge B.
"The data belongs to the Organization, not the Application." It is good to keep this in mind, in addition to all the advantages and disadvantages pointed out in the answers. If the company wants to make use of this data in a way different from what has been designed (e.g., data Mining, integration with external systems, etc.), is the system an obstacle to this? If the answer is "yes," we have a lock-in potential - what is "good" for developers but bad for the client.
– mgibsonbr
Excellent answers provided here below! It will be interesting, if in fact you join the team, to publish a feedback here of the real situation (in conceptual terms on top of what was answered, nothing that hurts the company, of course).
– brasofilo
@mgibsonbr edited the answer p/ reflect what you said. I do not believe that there are many cases where you are completely free from the lock-in. When you choose a model, you cling to it and it’s never easy to get out of it. Of course, if you own the model, it’s a little easier, but I don’t think it makes much difference whether you’re in DB or not, the property does. In theory Windows has disadvantages, and even has. In practice companies do not care about this and care about more tangible things. Lack space p/ explain better :) Good suggestion of brasofilo.
– Maniero
The large volume data processing by a Stored Procedure can be more manageable than retrieving this data over the network to process it in the application, simply because the routine it processes is closer to the data. There is no none another advantage. All the advantages cited by Gypsy and bigown can be enjoyed also when programming the business rule in the application. And even this one I mentioned is quite questionable because there are many architecture models to solve performance problems without having to implement the business rule in DBMS.
– Caffé