Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create indexes in a right way?
Message
From
02/04/1998 09:24:32
Andrzej Majlich
Vulcan sp. z o. o.
Wroclaw, Poland
 
 
To
02/04/1998 08:03:52
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00088690
Message ID:
00088922
Views:
37
>First, a deleted record doesn't mean you could use its PK value, unless packed. So it would be meaningless to use a filtered key or a tag on deleted() just for PK check (a dummy tag on deleted() have always purpose, but not this one).

If you think about surrogate keys (with no meaning to the user). But when we regard a non surrogate key, we need filtered , candidate tag. Example - an invoice: a consecutive number of the invoice.

>With a generator routine you could be 100% sure that a key is unique w/o checking it. Of course you would need some checking on startup.

We are entering the area of Murphy laws.
But I must agree with your notice about nonsense surrogate key checking before TABLEUPDATE(). Such checking has to be performed just before saving the record and after locking the table.
LOCK...
DO WHILE .T.
   lcKey = generate(...)
   IF !SEEK(lcKey)      && You only seek your buffer+physically written !
      EXIT
   ENDIF
ENDDO
REPLACE Tag_PK WITH lcKey
TABLEUPDATE
UNLOCK
After articles in FoxPro Advisor presenting speed advantages of INTEGER keys, I decided to use as surrogate primary keys only such keys. That's why I don't suggest using SYS(2015).

Thanks for your notices.
_________________

*|| Andrzej [NJ].
Previous
Reply
Map
View

Click here to load this message in the networking platform