0

i.e, can we just use stored procedures for everything? In a web-site backed by a DB that is.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Ada
  • 3
  • 1

2 Answers2

1

Stored Procedures have their benefits:

  • Minimize traffic back & forth between the application & database, wasting bandwidth
  • MVC: Separation of persistence layer
  • Scale loads better than application code (IE: ORDER BY will always trump application code)

Stored Procedure Cons:

  • Database dependency - ANSI is becoming more widely supported, but stored procedure code (not the query/queries in them) is not standardized at this time

Conclusion

Yes, stored procedures & functions can do most of what you'd probably ever want to do with data. The decision to use them is determined by design choices - to be database agnostic, most would not use stored procedures. Choose what best suits the requirements, not your preference.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
  • 1
    With regard to the original question - using stored procedures 'for everything' - it's almost certainly a very bad idea. – magma May 04 '11 at 05:36
  • as in "Yes, stored procedures & functions can do most of what you'd probably ever want to do with data", you mean? I agree. – magma May 04 '11 at 16:38
  • @magma: "most" isn't an absolute, while "almost certainly is a very bad idea" is dangerously close. – OMG Ponies May 05 '11 at 00:37
0

In short: no. And, that's probably a bad idea.

See: Arguments for/against Business Logic in stored procedures

Community
  • 1
  • 1
magma
  • 8,432
  • 1
  • 35
  • 33
  • Thank You - golden answer here – Ada May 04 '11 at 05:03
  • Not a great question to refer to - the issue is subjective/argumentative, and really depends on the application design. – OMG Ponies May 04 '11 at 05:07
  • @omg *Because* the issue is subjective *and* it depends on the application design *and* we don't know much about Ada's application design, it's a worth read. – magma May 04 '11 at 05:35
  • So, you're unable to ask for clarification? Or just unwilling, when you could've supplied the link on the premise of being an exact duplicate? – OMG Ponies May 05 '11 at 00:38