![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
A database driven application should be modelled with normalized tables with a mind towards OLTP processing. Developers can select from the database in anyway they want, but are provided no means to insert, update or delete database data. |
|
Instead, all updates and deletions are provided to the developer via stored procedures. The motivation for controlling insert/update/delete is to ensure that all changes to the database preserve entities and relationships. It also prevents developers from "E-R Creep" --- that is, it prevents developers from fattening their controllers and views with implicit entities and relations that they identify and build in program code in an unstructured, undocumented fashion. |
|
It is important to realize that an application should have a MODEL not a RELATIONAL DATABASE. A database access layer is not a model. Program code that subtly creates entities and relations is not a model. A MODEL is created via a well-normalized E-R model whose integrity is guaranteed via well-documented mutation via DBA-developed stored procedures only. |
#4
| |||
| |||
|
|
I'm going to take a position in this post, and I welcome support or refutation of my position. I also strongly request references to books and web links on this subject. Here it goes: A database driven application should be modelled with normalized tables with a mind towards OLTP processing. Developers can select from the database in anyway they want, but are provided no means to insert, update or delete database data. Instead, all updates and deletions are provided to the developer via stored procedures. The motivation for controlling insert/update/delete is to ensure that all changes to the database preserve entities and relationships. It also prevents developers from "E-R Creep" --- that is, it prevents developers from fattening their controllers and views with implicit entities and relations that they identify and build in program code in an unstructured, undocumented fashion. It is important to realize that an application should have a MODEL not a RELATIONAL DATABASE. A database access layer is not a model. Program code that subtly creates entities and relations is not a model. A MODEL is created via a well-normalized E-R model whose integrity is guaranteed via well-documented mutation via DBA-developed stored procedures only. When I worked at BEA, we loved customers wo did everything with stored |
#5
| |||
| |||
|
|
Databases should have data, and integrity constraints to keep the data clean. Business logic in the form of stored procedures does not belong in the atabase. |
#6
| |||
| |||
|
|
In article<b1813a63-d1f0-44b2-8853-eba10b6050a0 (AT) o8g2000yqo (DOT) googlegroups.com>, metaperl<metaperl (AT) gmail (DOT) com> wrote: It is important to realize that an application should have a MODEL not a RELATIONAL DATABASE. A database access layer is not a model. Program code that subtly creates entities and relations is not a model. A MODEL is created via a well-normalized E-R model whose integrity is guaranteed via well-documented mutation via DBA-developed stored procedures only. When I worked at BEA, we loved customers wo did everything with stored procedures. While sprocs were fast, they didn't scale very well. They needed our products. |
|
Databases should have data, and integrity constraints to keep the data clean. Business logic in the form of stored procedures does not belong in the database. |
#7
| |||
| |||
|
|
On 14.05.2010 06:17, EricF wrote: In article<b1813a63-d1f0-44b2-8853-eba10b6050a0 (AT) o8g2000yqo (DOT) googlegroups.com>, metaperl<metaperl (AT) gmail (DOT) com> wrote: It is important to realize that an application should have a MODEL not a RELATIONAL DATABASE. A database access layer is not a model. Program code that subtly creates entities and relations is not a model. A MODEL is created via a well-normalized E-R model whose integrity is guaranteed via well-documented mutation via DBA-developed stored procedures only. When I worked at BEA, we loved customers wo did everything with stored procedures. While sprocs were fast, they didn't scale very well. They needed our products. On what database did you have those SPs and why didn't they scale? Databases should have data, and integrity constraints to keep the data clean. Business logic in the form of stored procedures does not belong in the database. As always statements like these should be taken with a serious grain of salt. Unfortunately often you cannot ensure data integrity completely via constraints. You can do a few things via triggers but these are highly DB specific as well. When I think of those applications whose performance has been crippled via bad usage of EJB 2.1 then a clear procedural interface to the data written in stored procedures all of a sudden looks very attractive to me. You can save a lot of roundtrips that way. Granted, with modern EJB 3 you can make DB accesses a lot smarter and more efficient - but the general mismatch between the OO world and the relational world remains. These are really bad examples I have seen but the fact that development speed is reduced because you cannot easily change something can actually be positive. I know, all those time to market gurus will tell you differently but risking the integrity of the most important thing a business has in its IT world (its data) can have dramatic effects. While it may be good to be able to quickly extend the user interface this can have extreme adverse effects when applied to the data. The downside of the quick schema change is the schema migration that seems to be forgotten so often. The change that seemed so smart on the dev system might all of a sudden turn out a major nightmare with the customer's 56GB database which cannot afford downtimes of more than 5 minutes. Kind regards robert |
#8
| |||||||
| |||||||
|
|
In article<855b3bF3ioU1 (AT) mid (DOT) individual.net>, Robert Klemme<shortcutter (AT) googlemail (DOT) com> wrote: On 14.05.2010 06:17, EricF wrote: In article<b1813a63-d1f0-44b2-8853-eba10b6050a0 (AT) o8g2000yqo (DOT) googlegroups.com>, metaperl<metaperl (AT) gmail (DOT) com> wrote: It is important to realize that an application should have a MODEL not a RELATIONAL DATABASE. A database access layer is not a model. Program code that subtly creates entities and relations is not a model. A MODEL is created via a well-normalized E-R model whose integrity is guaranteed via well-documented mutation via DBA-developed stored procedures only. When I worked at BEA, we loved customers wo did everything with stored procedures. While sprocs were fast, they didn't scale very well. They needed our products. On what database did you have those SPs and why didn't they scale? Databases should have data, and integrity constraints to keep the data clean. Business logic in the form of stored procedures does not belong in the database. As always statements like these should be taken with a serious grain of salt. Unfortunately often you cannot ensure data integrity completely via constraints. You can do a few things via triggers but these are highly DB specific as well. When I think of those applications whose performance has been crippled via bad usage of EJB 2.1 then a clear procedural interface to the data written in stored procedures all of a sudden looks very attractive to me. You can save a lot of roundtrips that way. Granted, with modern EJB 3 you can make DB accesses a lot smarter and more efficient - but the general mismatch between the OO world and the relational world remains. These are really bad examples I have seen but the fact that development speed is reduced because you cannot easily change something can actually be positive. I know, all those time to market gurus will tell you differently but risking the integrity of the most important thing a business has in its IT world (its data) can have dramatic effects. While it may be good to be able to quickly extend the user interface this can have extreme adverse effects when applied to the data. The downside of the quick schema change is the schema migration that seems to be forgotten so often. The change that seemed so smart on the dev system might all of a sudden turn out a major nightmare with the customer's 56GB database which cannot afford downtimes of more than 5 minutes. Robert, I've seen scalability issues with Oracle and SQL Server where there was a lot of processing with sprocs. |
|
I think it is okay to put some logic in the database but very little, and that needed only to insure integrity. Databases have been optimized to work with data. When you start running business rules there, that is where you can get into trouble. |
|
EJB 2.1 can be abused as can any language. You can write miserable code in PL/SQL and T/SQL. I think it is a lot easier to write bad code in the sproc dialects because they are not really meant to be general purpose programming languages. |
|
I recently saw Martin Fowler, 1 of the agile gurus. He was advocating a database per application so you could move faster and the risk of bad data is localized. I do think that makes sense - for certain classes of applications. |
|
I worked for a company that had most of the BL in PL/SQL. The marketing people and development managers were unhappy because it took 6 months for the smallest change to be made. The new developers were unhappy because we were charged with moving the logic into a n-tier Java application - but we couldn't understand how the spaghetti worked. |
|
Your points are well taken. If you have a 56GB db, you don't want to make unneeded migrations. And data integrity is key. But don't make developers jump through hoops to get things done. And think about the ease of maintaining and the ability to scale when you design your systems. |
|
I was consulting at Turner Television in the late 90's. They needed an "advanced" search application where the user could select movies that were westerns and had John Wayne or dramas directed by Howard Hawks with leading ladies like ... you get the picture. We were constrained to doing the logic in PL/SQL. Luckily you could generate dynamic queries in PL/SQL. There were battles getting the DBAs to allow this. The string processing was ugly as sin. It actually worked reasonably well but it was unsupportable. This should have been coded in C or C++ or anything but PL/SQL. But the database team had these "Thou shalt" edicts that didn't always make sense. I hoped they stayed with Oracle. Porting that would be a nightmare. |
#9
| |||
| |||
|
|
On 15.05.2010 05:37, EricF wrote: I recently saw Martin Fowler, 1 of the agile gurus. He was advocating a database per application so you could move faster and the risk of bad data is localized. I do think that makes sense - for certain classes of applications. Yes, of course. I would consider that given - lumping different applications' data in a single schema is certainly a bad thing |
|
And think about the ease of maintaining and the ability to scale when you design your systems. I fully agree. And scaling is usually easier with application servers than with databases. |
#10
| |||
| |||
|
|
On Thu, 13 May 2010, metaperl wrote: Instead, all updates and deletions are provided to the developer via stored procedures. The motivation for controlling insert/update/delete is to ensure that all changes to the database preserve entities and relationships. It also prevents developers from "E-R Creep" --- that is, it prevents developers from fattening their controllers and views with implicit entities and relations that they identify and build in program code in an unstructured, undocumented fashion. I don't understand either of those concepts - either the idea that changes to the database might not preserve entities and relationships, or E-R creep. Could you give me some examples? |
|
To be honest, my visceral reaction is that you are exactly the kind of nutjob DBA who makes actually developing software a nightmare. However, i am conscious that this is my guts talking, not my brain. |
![]() |
| Thread Tools | |
| Display Modes | |
| |