comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Design help
Date: Tue, 13 Mar 2007 10:40:33 +0100
Date: 2007-03-13T10:40:33+01:00	[thread overview]
Message-ID: <1v79s2t3fjrxu.14pyinp46ngmp.dlg@40tude.net> (raw)
In-Reply-To: mailman.120.1173747027.18371.comp.lang.ada@ada-france.org

On Mon, 12 Mar 2007 19:50:11 -0500, Carroll, Andrew wrote:

> I hope to have the database records be variable length however it may
> make my life easier if they are fixed length due to the fact that some
> of the record structures contain pointers.  I guess that would be access
> type instead of pointer, anyway...

> Here are the record structures I have defined:
> 
>    type attribute is tagged
>       record

[...] 

Because attribute is not limited the compiler would generate assignment as
a shallow copy. That might get quite dangerous with pointers. Either it has
to be limited or strings need to be by-value (or by-reference counted smart
pointers).

> Obviously a database tuple could have any combination of these in it but
> luckily I only have to worry about 5 attributes in a database table
> schema.

Why don't you compose tuple types from attributes?

type Row is record
   Name : StringAttribute;
   Birth : DateAttribute;
   ...
end record;

Row could be read from stream.

However there is a problem of cross-platform portability. The blob you
read/write using stream attributes would be platform-dependent. If that's
the problem you'd need to override stream attributes or else derive all
types from some base type with Serialize/Construct abstract methods
(loosing automatic aggregation of rows as above).

(I used the latter approach in my persistence layer, that was in Ada 95
times. With Ada 2005 limited types, a platform-independent stream solution
could turn possible. It would be interesting to investigate when a stable
2005 compiler appear.)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2007-03-13  9:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-13  0:50 Design help Carroll, Andrew
2007-03-13  2:48 ` Randy Brukardt
2007-03-13  8:52 ` Stuart
2007-03-13  9:40 ` Dmitry A. Kazakov [this message]
2007-03-13 20:18   ` Simon Wright
2007-03-13 22:22   ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2007-03-26 14:56 Carroll, Andrew
2007-03-09 22:43 Carroll, Andrew
2007-03-09 23:07 ` Simon Wright
2007-03-10  1:00 ` Jeffrey R. Carter
2007-03-10  4:40 ` Steve
2007-03-10 13:38 ` Ludovic Brenta
2007-03-17 20:34 ` Michael Erdmann
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox