[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: SQL Constraints (was "losing out 'cuz 'o grammar")

  • From: Charles Reitzel <creitzel@m...>
  • To: xml-dev@l...
  • Date: Thu, 01 Feb 2001 11:20:27 -0500 (EST)

sql constraints
On Wed, 31 Jan 2001 19:37:56 Ken North wrote:
>> > Rules, due to their invocation at a points in time, 
>> > make inroads into the "route" (e.g. SQL triggers).  
>> > Declarative rules *use* grammar for their
>> > definition and depend on "grammar valid" data on 
>> > which to operate.
>> > 
>> > SQL didn't get basic triggers until 2.0.
>[snip
>> > Heck, most people never use triggers.  They just put it
>> > somewhere in the application code.
>>
>> Well ... I'd say that 'constraints' are 'closer'  than 
>> 'triggers'.

I use triggers. Most people don't, tho.  As a consultant, many is the time I
have introduced NOT NULL into a database schema.  Paul is probably right in
implying that Constraints are the standard part.  I haven't read the RFC, I
just work w/ whatever Oracle or Sybase give me ;~)

To continue Rick J.'s analogy, constraints describe facts about committed
data, are time-independent and, therefore, are part of the "map" and not the
"route".

>In the SQL world, there is often a division of labor 
>between database designer and application programmer. 
>The designer is the one who creates schemas, expressing
>constraints and specifying triggers. Skilled designers 
>look to declarative rules and constraints first, and then 
>use triggers if constraints are insufficient for what 
>needs to be done.

Well put.  Primary/Foreign key, unique key, non-null constraints are all
basic, portable(!) and do not incur undue "interference" w/ application
logic.  Sometimes it is necessary to denormalize for performance, and
database triggers can mitigate the associated "update anomolies", I think
they are called.  In essence, we are still in the static view of the data,
however.

>Using application code to enforce rules, instead of 
>declaring constraints that are managed by the container 
>(database), leads to versioning problems.  With 
>container-managed constraints, the rules are applied 
>uniformly across all clients connecting to the container. 
>With rules coded in application objects, you have to 
>co-ordinate application updates so the rules are 
>consistent from one program to the next. Different 
>programming languages, different namespaces, different 
>versions of classlibs -- it can be nasty trying to stay 
>in sync.

True enough.  But you can go too far the other way. 

What I try to avoid is writing full procedural programs in proprietary
languages.  In an environment where portability is not a concern (in house
vs. commercial) this is ok and you see a great deal of the application being
written as stored procedures.  To the extent this represents separation of
presentation from business rules, this is a good thing.  

When you split the source base into parts across two (or more) development
groups, coordination can get tricky.  The UI folks end up having to write
tricky routines to work around the particular, er, semantics of stored
procedures that are out of sync.  You also end up having endless variations
of similar routines, each called in one place.  You also can end up w/ a lot
of dead code because it isn't always easy to cross-reference the calls.

Your description of the problem is right on.  IMO, the solution is decent
engineering management practices and not technology, per se.  Ultimately, it
comes down defining a decent programmatic interface for that system and
sticking to it.

>In the XML world, we can now exploit types and constraints, 
>but one question is whether developers will learn from the 
>SQL experience, i.e., declarative, container-managed logic
>solves some of the proliferation/fragmentation problems 
>that occur with ad hoc application logic.

Schemas and database stored procedures do help.  But they (or anyplace the
logic happens to be kept) are just as susceptible to ad hoc updates.  Again,
it comes down to engineering management.  

The weight of the world does not rest on the schema language designers'
shoulders.  Somebody still has to write the app.

take it easy,
Charles Reitzel


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.