Dynamic array in database 
Author Message
 Dynamic array in database

Hello,

I'm working with delphi 5 and paradox 7 tables
I have the following problem:

I have a record

TRecord2 = record
    FieldA: String;
    FieldB: String;
    FieldC: Byte;
end;

TRecordArray = array of TRecord2;

TRecord1 = record
    field1: string;
    field2: string;
    field3: byte;
    field4: TRecordArray;
end;

Now here is my problem

    If Field3 = 3 then TRecordArray contains 3 elements, if 4 --> 4 elements
    How can I store, and retrieve this in/from a Paradox 7 DB

I think it must be possible with the Binary Type but I do not know how.

Could someone explain this to me, maybe with some Example Source.

Thanks in advance

Best regards

Van Tyghem Sean



Wed, 13 Aug 2003 22:00:00 GMT  
 Dynamic array in database
I don't recommend storing binary data in a database. I think it is better to
use 2 tables in this case:

Table1:
field1: string;
field2: string;
field3: byte;
(there is no need to store field4)

Table2:
field1: string;
FieldA: String;
FieldB: String;
FieldC: Byte;
(I am assuming here that field1 is unique for TRecord1 and that FieldA is
unique for TRecord2)



Quote:
> Hello,

> I'm working with Delphi 5 and paradox 7 tables
> I have the following problem:

> I have a record

> TRecord2 = record
>     FieldA: String;
>     FieldB: String;
>     FieldC: Byte;
> end;

> TRecordArray = array of TRecord2;

> TRecord1 = record
>     field1: string;
>     field2: string;
>     field3: byte;
>     field4: TRecordArray;
> end;

> Now here is my problem

>     If Field3 = 3 then TRecordArray contains 3 elements, if 4 --> 4
elements
>     How can I store, and retrieve this in/from a Paradox 7 DB

> I think it must be possible with the Binary Type but I do not know how.

> Could someone explain this to me, maybe with some Example Source.

> Thanks in advance

> Best regards

> Van Tyghem Sean



Fri, 15 Aug 2003 16:28:44 GMT  
 Dynamic array in database
I fully and strongly agree.  The format in your database should be one
that supports easy access to the data .. whether that is through your
program or not. This means that the routines need to be written which will
import the data into your program's records, and to save it back out
again.  A term that is sometimes used for this process, albeit in
different contexts, is "marshaling."

It should go without saying, of course, that [a] you need to use
appropriately descriptive field-names; and [b] you need to carefully check
for errors in both the loading and the unloading process.  

Your "field4" is an instance of a repeating-group.  There's a one-to-many
relationship between TRecord1's and TRecord2's.  It's fine to store the
data in-memory that way, for internal processing... nothing at all wrong
with that... but when it comes time to interact with the database, you
need to load and unload those in-memory data structures.  Mr. Avegaart's
design for this is entirely appropriate.


Quote:

> I don't recommend storing binary data in a database. I think it is better to
> use 2 tables in this case:

> Table1:
> field1: string;
> field2: string;
> field3: byte;
> (there is no need to store field4)

> Table2:
> field1: string;
> FieldA: String;
> FieldB: String;
> FieldC: Byte;
> (I am assuming here that field1 is unique for TRecord1 and that FieldA is
> unique for TRecord2)



> > Hello,

> > I'm working with Delphi 5 and paradox 7 tables
> > I have the following problem:

> > I have a record

> > TRecord2 = record
> >     FieldA: String;
> >     FieldB: String;
> >     FieldC: Byte;
> > end;

> > TRecordArray = array of TRecord2;

> > TRecord1 = record
> >     field1: string;
> >     field2: string;
> >     field3: byte;
> >     field4: TRecordArray;
> > end;

> > Now here is my problem

> >     If Field3 = 3 then TRecordArray contains 3 elements, if 4 --> 4
> elements
> >     How can I store, and retrieve this in/from a Paradox 7 DB

> > I think it must be possible with the Binary Type but I do not know how.

> > Could someone explain this to me, maybe with some Example Source.

> > Thanks in advance

> > Best regards

> > Van Tyghem Sean



Sun, 17 Aug 2003 10:56:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. dynamic array

2. How to store dynamic array to memofield?

3. Dynamic Type array

4. Dynamic Array puzzle

5. How to declare dynamic array in fpc ??

6. dynamic arrays

7. Memory access; relative position (dynamic array)

8. Heap error while allocating dynamic array in protected.

9. How do you do a dynamic array in oascal

10. Dynamic (list-like) arrays in Delphi

11. Dynamic arrays?????

12. Question: Dynamic arrays in Turbo Pascal

 

 
Powered by phpBB® Forum Software