Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unique Key Violation
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00245748
Message ID:
00246051
Views:
17
>Is it better to use an "automatically incrementing" numeric field as the primary key. In this case, the company we get the data from recycles the key field [an insurance policy number] -- I don't know how they do it. Sometimes we need to reuse the policy id after it has been deleted [a policy gets "reissued"], but we can't reuse the policy id if it currently exists -- don't want duplicate policy numbers. Is it better to just seek that record to see if it exists before adding the new record rather than worrying about making it the primary key?
>

Nope - add a surrogate key that uniquely identifies the record but doesn't carry any information in and of itself. That way, if the policy number is changed or reassigned, the record's primary key remains constant. A primary key should uniquely identify the record at all times, regardless of the record's status, otherwise, the relationships between tables can get confued.

You can obviously seek a record to see if it already exists. The real problem here comes from possible sequence of event errors, since the policy might not have been processed for cancellation before reissue.

>Thanks,
>Doug
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform