Re: Object Oriented Wrapper classes to SQL statements

From: Clifford Heath <cjh_nospam_at_osa.com.au>
Date: Wed, 12 Dec 2001 10:16:59 +1100
Message-ID: <3C1693EB.9F0C2370_at_osa.com.au>


Rachel wrote:
> If any of you know of existing packages (open source or commercial)
> that have such a model - please let me know.

It's not exactly what you're looking for, but I think you'd learn a lot from <http://www.orm.net/>. I think this approach to modelling and expressing queries is going to attract a lot of deserved attention.

As far as modelling queries using objects, you have to be aware of the fundamental transformation that an SQL parser makes. SQL is an Englishlike  grammar for a relational calculus (exists s such-that ....), and the parser transforms the abstract syntax tree into relational algebra operations like sort, join, filter, project, group etc. The optimiser then makes a bunch of algebraic manipulations on the tree, first using heuristics (like "filter-first") then cost-analysis to decide on a query plan - which is still in algebraic form.

If you want to model queries using objects, you should be looking at an object for each node type in the relational algebra, find a good way to present that to the user and allow it to be manipulated, then when you're done, produce the calculus (SQL) from the tree. The kinds of representations and manipulations required by a friendly query tool just aren't easy if you try to manipulate the calculus directly, but are straightforward if you look at the algebra.

--
Clifford Heath, ManageSoft Corporation
Received on Wed Dec 12 2001 - 00:16:59 CET

Original text of this message