Hi Peter,
Both Primary and Candidate indexes ensure unique values, including deleted
records, unless the index has "For Not Deleted()" (or similar) in the index
expression. That means that the database will "do the work" of ensuring
unique values and you won't have to write code (everywhere you add or change
records) to do it.
Since there can be only one Primary index, any other indexes requiring
unique values must be labeled as Candidate indexes.
A disadvantage to Primary and Candidate indexes, if they are for something
like pre-printed tickets, is that the ID value of a deleted record can't be
re-used, unless, of course, you locate the deleted record and recall it.
Some developers like to re-use deleted records. One way around the
uniqueness problem is to blank out the row, set the PK value to -1*TheValue
and then delete it. To recycle the record you can just Set Deleted Off and
Locate for Value < 0.
Hopefully some others will post comments to cover anything I've missed.
--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
***@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
Post by PeterI will like some pro and con in setting a field as primary or candidate.
Thanks.