Re: The Zen nature of a Delphi database application
- From: "Bjorge" <bjorge@xxxxxxx>
- Date: Mon, 19 Feb 2007 14:29:38 +0100
marek jedlinski wrote:
On Fri, 16 Feb 2007 23:37:18 +0100, "Bjørge" <bjorge@xxxxxxx> wrote:
I find myself writing less OO every day. OK, I use OO more for
metadata than for production data containers. If you don't need
polymorphism, don't use OO.
What about storing polymorphic objects in a DB? That's another bit of
a snag for me. What used to be a single collectin of
polymoprhically-accessed objects is now a number of different tables,
since each subclass needs its own set of fields.
One way is to use 1 table for all classes, consisting of 1 BLOB field for
object's data, a field "OID", "class", maybe "Caption", etc., meaning "all
fields you would need for retrieving and initial displaying without reading
the BLOB. Then you could use your good ol' streaming techniques, only put
objects separately into database records instead of a continous stream.
Most databases come with an ID generator, or you could create one.
Before creating any db record, get this ID. Stay away from "autoinc"
fields - the use of them cause your trouble.
Thanks for that :) When I learn about autoinc fields, I figure hey,
that's useful! But then it seems to make things harder than they need
to be.
--
Regards,
Bjorge Sather
bjorge@hahaittedotno
.
- References:
- The Zen nature of a Delphi database application
- From: marek jedlinski
- Re: The Zen nature of a Delphi database application
- From: Bjørge
- Re: The Zen nature of a Delphi database application
- From: marek jedlinski
- The Zen nature of a Delphi database application
- Prev by Date: Re: Editor component
- Next by Date: Executiing stored procedure
- Previous by thread: Re: The Zen nature of a Delphi database application
- Next by thread: question about Delphi and Visual Studio .NET
- Index(es):