The Zen nature of a Delphi database application



If I have a seemingly basic question about using a database in a Delphi
app, but can't find the answer in Borland manuals, or in samples, or in
Mastering Delphi 5/6, or in Developers Guide ditto, or really anywhere
else, then either it's something everybody else was born with, or it's one
of those Zen questions that defy reason. I've no idea which it is.

I've used Delphi for years, but am completely new to db-backed projects. I
want to use a database (tinkering with Nexus embedded, so far) because the
size of data makes loading it all into memory and writing out to disk when
user clicks Save unsuitable. I've studied SQL and database design a little
and know how to create tables, run queries, etc. In the application, what
will look like a unit of data to the user will actually be distributed
among three separate tables, joined on a UID. I am not going to use
data-aware components. So now for what I just can't figure out:

Should I (a) use database functionality ONLY, and connect query results
directly to UI controls, then write data from the controls to the DB? Or,
should I (b) read from the DB into objects that represent the data (a "data
model"), populate UI controls from those objects, then write data back from
the modified objects to the DB for storage?

I really want to do (b), but I'm getting nothing but puzzles when I try.
How can I build a list of my business objects, if I just said their data is
to be too big to fit in RAM (due to "blob" content)? If I load the whole
contents of the database into my business objects, then I'm missing the
whole point of using a database, aren't I?

Or: each BO has a read-only UID property, passed as an argument to the
constructor. I cannot construct the object without the UID, but I don't
have the UID until I have stored the object in the DB, since the UID is the
autoincrement field. This one really puts a damp on my thinking.

Or, if my BOs are shown in a grid, and the user edits a value in a single
object, should I update just the BO, or both the BO and the DB at the same
time? If just the BO, when's a good time to update the DB? And how can I
ensure that the two don't go out of sync if a write operation fails?

I feel that all these questions are aspects of one and the same fundamental
issue. I've never had any of these problems when working with stream-based
storage, of course. What is eluding me?

Kind thanks in advance,

marek


--
No ads, no nags freeware: http://www.tranglos.com

--
No ads, no nags freeware: http://www.tranglos.com
Skype: tranglos GG: 5967086

"Anyone who incites violence, other than those elected, will
have to face the law." -- Ethiopia's Information Minister Bereket
Simon, asked why the Ethiopian government arrested 14 opposition
leaders.
.



Relevant Pages

  • Re: Delphi Jobs
    ... I am a Delphi database programmer. ... Source Safe and Source Off Site on the server side and client side. ... design several pieces for the interactive website. ...
    (comp.lang.pascal.delphi.misc)
  • Re: The Zen nature of a Delphi database application
    ... I'm a database guy with very little Delphi experience so our skill sets are likely inverted images of each other. ... but spend my salaried hours working with Oracle so I've wound up with a lot of database experience. ... Using the dbaware controls they should take care of the autoincrement primary key (what you're calling a uid). ... If you were doing a banking application and had a function to move money from one account to another you'd only commit after both actions happened. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Embarcaderos Director of Products Blog
    ... What indications were there that it was difficult to sell, ... but Delphi has ALWAYS been about database development. ... All of which DO make perfect sense and could be seen as having a home at ...
    (borland.public.delphi.non-technical)
  • Software specifications
    ... I have been frustrated in this project because my software and hardware is ... another programmer who has been my mentor in Delphi, ... me when it will be ready, as they are struggling with old MSDOS software ... could do the entire database project myself, ...
    (comp.lang.pascal.delphi.misc)
  • Database Landscape for future Delphi work.
    ... I'm a died-in-the-wool Delphi fan, and have been programming in Delphi since ... So I switched my database to Jet 4.0 and to using ADO via Delphi's ... Good support for syncing w/ SQL Server. ...
    (borland.public.delphi.non-technical)