[fpc-pascal] How to insert a record and get the primary key with sqldb?

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Oct 24 12:39:05 CEST 2011


On 2011-10-24 12:13, Vincent Snijders wrote:
> 
> I consider this bad advice. GUID are bad primary keys, because of
> their size and the fact they are not sequential by design.

We did some speed tests between GUIDs (Char(36) as used by tiOPF which
strips some chars from a normal GUID) and Int, String type primary keys.
Yes GUID's were slightly slower, but not by a margin that the end-user
would notice.

The convenience of having a truly unique primary key even across
databases and having the primary key available before the data is
inserted into a database, far outweighed the cons. At least for us.

Regarding your comment about sequential primary keys. In my opinion, it
is highly debatable if PK should be in a sequential order or if its
values should in any way be related to the data or not. I strongly
believe it shouldn't relate to the data at all, just like I believe a
primary key must not consist of multiple data fields. To me, a database
is simply a storage location for my data. Primary Keys are simple part
of the data structure a database uses to retrieve my data.

Anyway, I have no intention to debate this further. The internet is full
of such message threads already. As I said, based on our needs, GUID's
was a perfect fit.

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/




More information about the fpc-pascal mailing list