>Hi,
>Hmm.. Is it the way?
>
>I have item, outlet, outletitem and stockin, stockindetails table.
>
>
>Table: item
>Field: ItemID (PK), ItemCode, ItemName ....
>
>Table: Outlet
>Field: OutletID (PK), OutletCode, OutletDesc
>
>Table: OutletItem
>Field: OutletItemID (PK), OutletID, ItemID, CPU, PPU ...
>
>Table: StockIn
>Field: StockInID, InvoiceNo, InvDate, ....
>
>Table: StockinDetails
>Field: StockInID, StockInQty, StockInCPU ....
>
>
>
>In my app, I allow user to stockin for multiple outlet in ONE sotckin transaction. Then, what is the foreign key for the item+outlet of stockindetails table? Should I just use OutletItemID or composite key or.. ??
The PK in one table becomes the FK in other tables that reference it. So, yes, you should use the OutletItemId. This will make your FK small (4 bytes), and this is precisely one of the advantages of this method.
>BTW, is it the way using auto generated value as PK?
I suppose you mean "what is the way to do this".
Use function SerialNumber(), which I pasted in
Re: Codigo character mas secuencia numerica Thread #
767447 Message #
767471. The message is in Spanish, but the function has comments in English.
HTH,
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)