Subject Re: creating unique key : usingprimair key and foreign key
From Alex Safian <noway@noway.com>
Date Fri, 05 Feb 2021 18:08:52 -0500
Newsgroups dbase.getting-started

Mervyn, are you saying not to use autoinc? I thought creating unique primary keys in a multiuser environment is exactly what autoinc was for. Otherwise, who needs it? What's it there for?


Mervyn Bick Wrote:

> In a multi-user system one can't guarantee that the last record in the
> main table is the one you've just saved.  Another user may have saved a
> record a fraction of a second after you.  SQL RDBMs make provision for
> a programmer to get the value of the primary key of a record just saved.
> dBASE doesn't. :-(
>
> The solution is not to use an autoinc field but rather use a separate
> sequence generator.  Primary keys do not need to be in numerical order
> in a table.  They just need to be unique.  If you want to list records
> in the order in which they were saved add a timestamp.  Get a value
> BEFORE saving the new parent record and use that.  There is code in the
> dUFLP (seqval.cc) to do this.
>
> Mervyn.
>