Re: Business objects, subset of collection
- From: frebe <frebe73@xxxxxxxxx>
- Date: Thu, 24 Jan 2008 07:52:05 -0800 (PST)
select i.invoiceidOnce again, if that is all you are doing, that is CRUD/USER processing;
from invoice i join payment p on i.invoiceid=p.invoiceid
group by i.invoiceid
having sum(p.amount) < i.amount and datediff(now(), i,duedate) >= 10
This is the kind of code I write every. Even though the number of
invoices and payments are very high, the queries perform within a
number of millis. The customer is happy, I am happy.
you are just moving piles of data back and forth between the UI and the RDB.
Maybe you can show your code performing the same task.You want code for inventory forecasts? A Linear programs to allocate
advertising budget to various markets' media? A simulation model of
atmospheric diffusion?
No. I was asking for the OO equivalence for the SQL statement above.
What's the point? Sure I could write AAL or OOPL code to do that. But
the main point here is that one would not want to solve the problem that
way unless there was no other alternative.
The problem is to create reminders for all invoices are not payed and
due date is passed since 10 days. The solution in SQL
could look like.
insert into reminder (invoiceid, remind_date)
select i.invoiceid, now()
from invoice i join payment p on i.invoiceid=p.invoiceid
group by i.invoiceid
having sum(p.amount) < i.amount and datediff(now(), i,duedate) >= 10
If you want to solve the problem another way, you are welcome. There
are of course other alternatives. The question is if they are better,
or not.
IOW, you are providing a common generic data access query problem and
asking for an OO equivalent. But I'm talking about solving customer
specific problems, not generic data storage access problems.
This is a customer specific problem. The problem has very little to do
with storage.
The OO
solution would be tailored to a specific problem so it would very rarely
have need of that approach.
The solution (SQL code) is tailored to the specific problem.
That's kind of the point. The "algorithms" for CRUD/USER processing are
very similar because they all solve the same problem: converting RDB
views of the data to UI views and vice versa.
My example aboive has nothing to do with UI.
Caching is managed by the database. Caching is not the concern for theNonsense. Every non-CRUD/USER application I have ever seen had a
application designer.
client-side cache in some form. By the time the requests get to the
DBMS, it is too late. The DBMS caches just manage server access and
resources (unless you are talking about memory mapped OODBs). One caches
on the client side to minimize DB access.
Another way to elminiate the inter-process communication overhead is
to use stored procedures for "complex processing". That is why most of
TPC (www.tpc.org) implementations rely heavily on stored procedures.
Obviously you could also use a memory mapped SQL database.
The web site didn't have a whole lot to say about stored procedures (but
I didn't plow through all the papers). However, I don't think it has
much to do with the point. There are four contexts of stored procedures:
(1) Enforcing data integrity constraints on the data storage itself.
Such stored procedures are triggered directly by write operations. That
makes a whole lot of sense since data integrity is pretty important to
data storage. It also makes sense to optimize those procedures to the DB
engine.
(2) Application modules that are executed on the client side but are
stored on the server side. This is common in RAD environments because
the event code needs to be stored and managed transparently somewhere
/within/ the IDE. However, it actually adds overhead to the application
because the stored procedure needs to be read from the DB into the
client execution space rather than being there initially (e.g., as in a
compiled image).
(3) Application modules that are executed on the server side at the
request of the client. These are also common in RAD environments and
usually consist of stored queries or joins. For these to execute on the
server side all they can do is extract/update data in the DB because
there is no mechanism for interacting with the client's data structures
_as they execute_. IOW, what one is storing are CRUD/USER operations on
the stored data whose timing is dictated by the application.
(4) Application models that capture business rules and policies and are
triggered by other data accesses on the server without the application's
knowledge. This is, indeed, more efficient because they can be optimized
around the DB engine. It is also a maintainability nightmare for large
applications. Any application developer that creates such stored
procedures should have their thumbs broken.
In summary, (1) is part of the DBMS franchise; (2) actually adds
overhead; (3) is only useful for CRUD/USER processing (or to handle DB
access for the application); and (4) should be grounds for summary
dismissal. So what is the benefit of stored procedures for a
non-CRUD/USER application?
You are ignoring two other scenarios:
1. You need a user-defined function in your SQL statements. (select
age(birthdate) from employee)
2. Performance reasons. By putting "complex processing" inside the
DBMS, you can eliminate the inter-process overhead and have major
performance improvments. Browse the source code for one of the TPC
implementations, and you will see how they do it.
SQL databases excel in CRUD/USER processing, which is what I keep
saying. Conversely, they suck once one gets out of that realm.
Since your definition of CRUD/USER since to be extremly wide, I am
quite happy with this statement.
How is it extremely wide?
Any example I have given you, you have classified as CRUD/USER.
At a fundamental level CRUD/USER applications
only solve one problem: data view conversions.
The example I gave you is not about data view conversions.
They are limited to the
very fundamental tasks of creating, extracting, updating, sorting,
reporting, and deleting data stored in persistent storage.
It is like saying that the only thing a CPU do is the fundamental
tasks of adding bits.
The crucial
thing that they do not do is solve specific customer problems (i.e.,
manipulate data to produce nontrivial results).
I have showed examples of the opposite. SQL statements may solve very
specific customer problems.
//frebe
.
- Follow-Ups:
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Re: Business objects, subset of collection
- References:
- Business objects, subset of collection
- From: jimbalo22
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Re: Business objects, subset of collection
- From: frebe
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Re: Business objects, subset of collection
- From: frebe
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Re: Business objects, subset of collection
- From: frebe
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Re: Business objects, subset of collection
- From: frebe
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Re: Business objects, subset of collection
- From: frebe
- Re: Business objects, subset of collection
- From: H. S. Lahman
- Business objects, subset of collection
- Prev by Date: Re: Business objects, subset of collection
- Next by Date: Re: Business objects, subset of collection
- Previous by thread: Re: Business objects, subset of collection
- Next by thread: Re: Business objects, subset of collection
- Index(es):
Relevant Pages
|