Re: Unknown SQL
Date: Sat, 21 Jul 2001 18:02:26 GMT
Message-ID: <9d74qs$rcc2_at_cui1.lmms.lmco.com>
"Philip Lijnzaad" <lijnzaad_at_ebi.ac.uk> wrote in message
news:u7wv7xaycl.fsf_at_sol6.ebi.ac.uk...
> Do you mean something like
>
> UPDATE Customers c
> SET c.balance = c.balance +
> (SELECT SUM(amount)
> FROM Payments p
> WHERE c.custid = p.custid
> AND p.date > c.last_update
> HAVING SUM(amount) > 0.0) ,
> c.last_update = TODAY()
> WHERE c.credit_rating < 3;
>
> If OODBMs offer this, excellent. I haven't seen the query capability
> necessary for this yet, though.
At the risk of stirring up the dogs and cats, I would question the validity of this statement. One of the criticisms leveled against the object databases is that they are too tightly coupled to the application. However, the above data model is fraught with application implementation details. There is a customer record (in table Customers) that stores a calculated balance. This balance is not necessarily up to date with all the financial transactions credited to this customer, so the data is not necessarily coherent. Sure, the customer record has a last update field, but that is purely an implementation detail, not intrinsically part of the data model.
OO theory (forget about the database part for a minute) says that you should model your data around your domain. This is the most stable part of your system because the real world doesn't change nearly as fast as algorithms or programming languages or even data storage/retrieval mechanisms.
So, a row in the Customers table is analogous to a Customer object. An accessor method, get_balance() could return the precomputed, cached (if potentially out of date) balance attribute stored with the Customer object (just as the relational model above) or it could compute it on the fly by accessing the transactions (both credits AND debits) associated with this customer. The difference is that the OODBMS will not have to do the join (WHERE c.custid = p.custid) because the transactions associated with a customer are already associated with the customer, allowing direct access.
How is the RDBMS superior there? Received on Sat Jul 21 2001 - 20:02:26 CEST
