Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin Transaction
Message
 
 
To
29/09/2016 06:02:10
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01641395
Message ID:
01641482
Views:
32
>>>>Code column seems to identify the product, I think it can be used as PK.
>>>
>>>A sales invoice might have product codes more than once.
>>>So code column can not be used as primary key.
>>
>>So, what is the key - the invoice_no, product code + date ?
>
>I think no,
>Please imagine what will be the primary key if table has data like this
>
>vou_no--code---Product---qty---rate--Amount
>---1-------1401----Apple------10----15----150
>---1-------1402----mango-----20----15----300
>---1-------1401----Apple------10----12----120
>---1-------1401----Apple------12----16----180
>---1-------1402----mango-----20----13----260
>
>code 1401 was used 3 times due to different rates
>code 1402 was used 2 times due to different rates
>
>In this situation, is there any chance to create ID?

Sounds like vou_no, code and Rate are the PK. Alternatively we can just add auto-increment identity column to be a PK and the combination of vou_no, code, Rate will be unique index.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform