Re: No knowledge of the database?

From: Daniel Parker (danielaparker_at_hotmail.com)
Date: 01/07/04


Date: 7 Jan 2004 09:18:29 -0800

fredrik_bertilsson@passagen.se (Fredrik Bertilsson) wrote in message news:<31f7e57d.0401062250.677aba3@posting.google.com>...
> > Your classes should be as independent of the database as possible.
> > Changing the table structure or database vendor should have little or no
> > impact on the client code or the external interface to your module.
> >
> Calum,
> can you give me an example of a table structure change you have done
> that have not changed the external interface of your database module?
> Your advise sound nice in theory, but it does not work in the real
> world. I have been doing like you say for some years, but in almost
> every case, a change in the database structure affects the code in the
> rest of the application, all the way to the client.
>
A select statement itself encapsulates the details of the individual
tables that data is coming from, and allows aliasing of column names.
The results come back to the client with a complete set of metadata
that describes the data types and column names. So, through the
select statements in views or stored procedures, you have the
flexibility of making significant changes to the physical table
structure - splitting one table into two, changing table column names,
etc. - without affecting client code. Assuming that your client code
has a binding layer that makes the appropriate type conversions to
client types, changes to database types such as varchar to date can
also be handled transparently, where they make sense. Similiar
statements apply to updates and inserts.

I've seen one project where we literally raised the app and replaced
one 150+ table database with a rather different one with minimal
initial changes to client code (more changes were later phased in.)
That was a while ago and the app was written in C against a Sybase
database, using stored procedures, and there was a signifcant amount
of infastructure to support the binding layers, including a data
dictionary and metadata support. This kind of thing is vastly simpler
with languages like Java and C# that support reflection.

Tools that support data binding from SQL result sets to the properties
of classes make a great deal of sense, provided that what's being
bound to are the results of queries. If tools would leave it at that,
they would be great. Where some of the OO data binding tools go wrong
is to do all this other stuff, for example, caching that makes no
sense (stand upTopLink), mandatory two part navigation strategies
(first get all the keys and then get the rows one by one), imposing
restrictions on table design (e.g. numeric id required.)

Regards,
Daniel Parker



Relevant Pages

  • Re: Unbound Data Access
    ... Instead of attempting this in client code, ... creating a stored procedure to handle the problem? ... the sproc, which performs the computations and inserts the data into ... database or on the same server. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: how does one trap for out-of-memory errors?
    ... >> I can't imagine how I can hide the database from the client code if I ... >> use database return resources, ...
    (comp.lang.php)
  • Re: What is a good strategy for joining data from separate databases
    ... One is my application's own database, and the other is a Data Mart created for me with a view I access. ... My current .NET business object merely makes a single stored procedure call to retrieve a resultset, with any joins required handled by the stored procedure. ... It is now considered unacceptable to have a dependency like that in the stored procedure and I need to re-structure the data access such that the .NET business object retrieves data separately from each database eliminiating the need for one database to be able to be linked or even aware of the other. ... Construct the SQL for a cross-database JOIN in client code ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Bussines objects
    ... against using database design as the foundation for class design. ... ID (unique ID held internally, not used in client code, just by storage) ... Customer ... Joanna Carter ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: What so special about PostgreSQL and other RDBMS?
    ... That's exactly the link the licence agreement for the database points to when it ... comes to what wecan expect for paying support. ... > "Oracle may provide additional releases or versions of its programs ... If the requirements are volatile I'd do a long term contract detailing what ...
    (comp.lang.php)