Re: Storing where clause

From: Jan Hidders <jan.hidders_at_REMOVETHIS.pandora.be>
Date: Fri, 20 Aug 2004 19:37:41 GMT
Message-ID: <pan.2004.08.20.19.39.34.136179_at_REMOVETHIS.pandora.be>


On Fri, 20 Aug 2004 00:57:30 -0700, Nagraj Kini wrote:
> Right now the where clause is stored as a string which I am not too
> thrilled about. I want to provide a UI so that the application admin
> can himself add the where clause and he dosent call me everytime to
> change the clause or add a new one. Storing it as a string is easy but
> when he needs to edit it, I will have to write the entire string
> parser which I dont want to do.

If there is an XML parser available you could store is as XML, or invent your own textual representation for which a trivial parser is possible.

> To give a brief idea the requirments are like this:-
> 1) Each screen has one table which defines all the parameter for the
> subset.
> 2) I need to provide a where clause based on these params.
> 3) The general structure of the query is like this
> where param is (not) in ( 'value1','value2') and/or ....

Ah, there is you data model right there. :-) You just have to translate it to tables. Try making an ER model first, like for example:

Entity type: WhereExpr
Relationships: WhereExpr.is.BoolExpr

Entity type: BoolExpr

Relationships: BoolExpr.contains.InExpr
               BoolExpr.contains.AndExpr
               BoolExpr.contains.OrExpr

Remark: these three relationships are mutually exclusive

Entity type: InExpr
Attributes: negated (type: boolean)

            values (type: set of values)

Entity type: AndExpr
Relationships: AndExpr.containsLeft.BoolExpr

               AndExpr.containsRight.BoolExpr

Entity type: OrExpr
Relationships: OrExpr.containsLeft.BoolExpr

               OrExpr.containsRight.BoolExpr

Note that you may need surrogate identifiers.

  • Jan Hidders
Received on Fri Aug 20 2004 - 21:37:41 CEST

Original text of this message