Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Surrogate Keys - Have I got the right idea
Message
De
12/01/2001 03:46:11
 
 
À
12/01/2001 02:43:59
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00434523
Message ID:
00462824
Vues:
23
Thanks Walter

I will try what you suggest, it certainly does seem like a simple method (therefore probably the best).

However I wonder if the fact that I now have 2 records with the same PK in my table (albeit one is deleted) is ever going to cause me problems in the future.

In the method I suggested earlier, I had spotted the problem of deleting a record twice as soon as I had sent the message to UT :(

However it occurs to me that this problem can be avoided by using a new -minus based PK key.

So in my getkey tables I have a minus key KEY_DELETED and I use this key to replace the PK in any record I delete.
Obviously I would have to do all deletions via a function and this would slow deletions down.

The way you mention is superior if I can be sure I will not run into trouble with the technique.

Many Thanks



>Hi mark,
>
>I don't think your proposal is neccesary and might cause problems when deleting a certain record twice.
>
>If in your case, the deleted records in the target table is the only problem, I think by filtering the PK on deleted() will solve your problems nice and clean.
>
>Just give it a test: Open the target table exclusively, open it in de table designer (MODIFY STRUCTURE), go to the indexes tab, select the primary key, and type: !DELETED() in the filter column.
>
>For rushmore optimizations reasons, add another regular index on the primary key: (For example: INDEX ON MyPrimaryKey TAG PK2 )
>
>No just try what you're trying to do again.
>
>Hope this helps.
>
>Walter,
>
>>How does this sound as a solution to my updating problem using surrogate keys.
>>
>>To avoid getting an update problem I convert the PK in my target table to a minus amount. I then delete the record and cascade any deletes that are neccesary if more tables are involved.
>>
>>Because the deleted records in the target table now have a different PK I can append in my new records (which contain the original positive PK)
>>
>>I realise that this can be a bit inefficient in some circumstances but I can think of a lot of circumstances where it would be the simplest way.
>>
>>Assigning a minus PK to deleted records would also have the advantage of allowing me to start recycling deleted records again like I did in the old days.
>>
>>Am I about to make a big mistake .
>>
>>Please let me know
>>
>>Thanks:)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform