Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primary Key
Message
From
08/01/1999 07:29:53
 
 
To
05/01/1999 21:56:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00171828
Message ID:
00173961
Views:
21
>>
>>This is 4 of a number of reasons to favor surrogate keys. There are many other reasons too.
>
>>WOW... You seem to know a little about this stuff. I think I followed most of what you said. Can you help me apply this to a common struggle I have with the following...
>
>A purchase order parent table with a character keyfield called "po_num", and a line-item child table with a "po_num" keyfield linking one or more child records to a single parent record. Now then, if I need a method of re-arranging the child records (like if a user wants to insert a line-item between the 2nd and 3rd line-item) I have always used an numeric field in the child table with a compound index of "po_num+item_no" and automatically assigned the "item_no" value in 10 increments (like old BASIC line numbering). This way, the user can add line-item 25 between line-item 20 and 30. If you auto-assign the "item_no" value in increments of 1, there is no simple "insert between" scheme.
>
>Is there a better way to handle this data model?

Instead of a numeric line number, you could use a character field with, say, 5 characters. The first time, "number" the items with letters like "A", "B", "C"... If you want to insert something between two items, you can use two letters: "AB", "AC", "AD". For repeats, use a third letter: "ABA", "ABB", "ABC", and so on.
Previous
Reply
Map
View

Click here to load this message in the networking platform