r/FullStack • u/tillas_ • 16d ago
Question Why implement procedural programming inside an RDBMS (MariaDB) instead of handling all business logic in backend application code?
So I have just seen the procedural programming language in the MariaDB RDBMS. So my question is, why in a relational database management system would you need SQL to also have the power of a programming language? Why in the layer of the database server would you need that? Can that be achieved with your backend server logic programming language, whether it be JavaScript, PHP, Python, Rust, Go, etc.? Why is there a programming language, why SQL is a programming language more so than just for querying and interacting with a database or databases? How does that fit into the full picture of full stack web development?
Edit: Thank you everyone for the thoughtful responses, technical insights, and feedback. All of this input is extremely helpful much appreciated!
View all comments
1
u/AQuietMan 16d ago
Imagine your backend consists of one JavaScript program, two PHP programs, three Python programs, four Rust programs, five Go programs, etc.
One alternative is to implement business logic once in dbms stored procedures.
Another alternative is to implement the business logic at least 5 times--once in each application language--with identical behavior. *And" maintain identical behavior in the face of version rollouts, application bugs, application language bugs, bug fixes, etc.
Which alternative carries the bigger risk?
I once worked on a db2 database at a Fortune 500 company. I saw programs in two dozen languages hit that database. I'm sure there were others that I didn't have access to. The first version of some of them went to production in the 1970s.
The notion that only one program can access the database is naive. You always have at least two: the application program, and the dbms command-line interface.