The Zen nature of a Delphi database application
- From: marek jedlinski <marekjed@xxxxxxxxxxxxxxxxx>
- Date: Thu, 15 Feb 2007 02:13:17 +0100
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.
.
- Follow-Ups:
- Re: The Zen nature of a Delphi database application
- From: Bjørge
- Re: The Zen nature of a Delphi database application
- From: Maarten Wiltink
- Re: The Zen nature of a Delphi database application
- From: Jason King
- Re: The Zen nature of a Delphi database application
- Prev by Date: Re: TaskBar flash and progress display, and fsStayOnTop
- Next by Date: Re: TaskBar flash and progress display, and fsStayOnTop
- Previous by thread: TaskBar flash and progress display, and fsStayOnTop
- Next by thread: Re: The Zen nature of a Delphi database application
- Index(es):
Relevant Pages
|