educative.io

Never use stored procedures? How silly

Um this course is telling me that I should never use stored procedures. As a database developer, I can tell you there will be times when you need to use stored procedures. They don’t make this feature for nothing you know?

Hi @Van_Jordan
The course/lesson is not about that we should never use stored procedures.
The single responsibility principle is: stored procedures enable us to add business logic to the database. A database should not hold business logic. It should only take care of persisting the data that’s why we have separate tiers for separate components.
So, the lesson suggests never holding business logic or using stored procedures when explaining the principle of single responsibility. Don’t confuse the purpose of the course with explaining a single responsibility concept.
Hope it will help , Thank you :blush:

Hey - a follow up.
So storing business logic in the database is bad ?
Well the data structure is due to the Business logic ? right?
So how can you avoid business logic from persistence?

Maybe what you are saying is don’t process data …in that “stored procedure” encapsulation?
So I hv 2 questions

  • would you need to process business logic on data/records /documents and store them back? into Modified or Newer records? I think that’s unavoidable.
  • What better alternative exists? please? (stored procedures are perfect for this …logical processing ! why? coz you hv to process and you want to process fastest). Either way, even if you have another layer / logical tier …pulling, processing and restoring data …that logic exists and is documented and is maintained and is ported/migrated …when you do change that processing (whether you change the DB type or not), the maintenance, extensibility rework stays and is not eliminated? no?

Could you please help, elaborate?