Board index » delphi » DB Structure ?

DB Structure ?

Hi all,

I'm new to this group and have a question that will most likely sound
elementary.  I coded with clipper years ago.  I'm playing with Delphi now
and find it great.  I have a fundamental question of dbase file design and
use of autoincrement field (paradox 5 table).  I thought that I would use an
autoincrement field to assign new id numbers as a key field.  Then set a
relation to several other files based on this key field.  But the other
files can't have an auto increment field for the id.  And there's where I
get confused.  Anytime I try and set relations I run into a mismatch
datatype or something along those lines.  I've got four books sitting here.
One is specifically Delphi Database Development, the other Mastering Delphi,
and Delphi Nut's and Bolts.  Can't seem to locate any clarification.  Also
am scouring web sites for information.

Any help would be most appreciated.

Tony

 

Re:DB Structure ?


Quote
> I'm new to this group and have a question that will most likely sound
> elementary.  I coded with clipper years ago.  I'm playing with Delphi now
> and find it great.  I have a fundamental question of dbase file design and
> use of autoincrement field (paradox 5 table).  I thought that I would use
an
> autoincrement field to assign new id numbers as a key field.  Then set a
> relation to several other files based on this key field.  But the other
> files can't have an auto increment field for the id.  And there's where I
> get confused.  Anytime I try and set relations I run into a mismatch
> datatype or something along those lines.  I've got four books sitting
here.
> One is specifically Delphi Database Development, the other Mastering
Delphi,
> and Delphi Nut's and Bolts.  Can't seem to locate any clarification.  Also
> am scouring web sites for information.

Tony,

    The first problem is using autoincrement fields for a key field.
Autonumber fields can possibly be regenerated later when repairing table
errors so they could change. It is best to use a straight integer field and
keep a separate table to keep up with the next key in the sequence. This
gives you full control and limits the problems.

    Even if you do use autoincrement fields, all other child tables will
need a straight integer field that is linked to the key field in the master
table. This is because the child table fields will need to be updated with
the key and you can not change an autoincrement field manually.

Woody

Other Threads