Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random keys for formerly separate tables
Message
De
16/07/1997 06:56:22
Vinod Parwani
United Creations L.L.C.
Ad-Dulayl, Jordanie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00040036
Message ID:
00040166
Vues:
42
>>>So I have all these keys, which are both unique and useful for ordering. When a record is added, I get the values from the textboxes, make a key with genkey(), and INSERT INTO tablewhatever(keyfield, field1, etc.) VALUES newkey, fieldval, etc. I'm content to go on doing that, but some people here (I believe Barbara Paltiel was one) have said that primary keys should only be used for their uniqueness, and should be generated by incrementation or random methods. I didn't understand their reasons, and I didn't want to ASSUME, though I'm free to SUPPOSE, that I'm smarter than everybody else.
>>
>>
>>I want to ask you one more question, suppose if a user modifies any of these fields then how will keyfield's values be changed, I mean isn't there any chance of duplication...
>
>All my apps do keyvalue = genkey(value1,value2,value3), then INSERT INTO table(keyfield,field1,field2,field3) VALUES (keyvalue,value1,value2,value3) and then TABLEUPDATE. That is a good point, though. Right now, if you attempt to enter a duplicate, there is an error message and a TABLEREVERT. In my current standalone environment, no harm is done. I don't want to allow users to make duplicates, as defined by field1, field2, and field3. I realize that, in a multi-user environment, the potential for harm is greater. But I'm not sure what I'm risking, doing it my way...

So, that means, if a user keys in the wrong data first time, then he can't change..

secondly, how will be the keyfield value affected, if another field is added..

Conclusively, i will say its risky, but as you wrote before, you can judge all the advantages and disadvantages of the above method, and if you think its fine then ok..
otherwise make a seperate unique field.

I asked you all these questions, because I was keen to know if there is any other method which can substitute the standard coding, so that I can also use in my projects but speaking honestly, I will stick to unique field system only..
Thanks for taking out your time and giving me replies...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform