Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2016
    Posts
    1

    Need to decide foreign and primary Key

    Hi,
    I am coming from networking background. I am troubling to decide foreign and primary key for the following database.

    Click image for larger version. 

Name:	Untitled.png 
Views:	4 
Size:	11.9 KB 
ID:	17142

    Primary functionality of these tables are :

    1) Items tables include unique entry products
    2) In purchase table, entry can be only made for the product if that product exist in items table. There fore, ITEM_ID in Items Table is unique but in purchase table it can be replicated.

    So i am not sure what to make as a foreign key and primary key.

    My assumption is: make item _ ID --- Items -- Primary Key

    Order_ID -- Purchase Table-- Primary Key

    but when will foreign key will come in? which field i should set it up?

  2. #2
    Join Date
    May 2016
    Posts
    89
    Hi Kam.gee

    I suggest this conceptual (CDM) & logical data model (LDM)

    CDM
    Click image for larger version. 

Name:	purchase_CDM.jpg 
Views:	7 
Size:	70.5 KB 
ID:	17143

    LMD
    Click image for larger version. 

Name:	purchase_LDM.jpg 
Views:	4 
Size:	48.5 KB 
ID:	17144

    If you use a tool like Power*AMC (paying) or JMERISE (freeware) with basic knowledge about modeling data base, all your problem will disappear
    Last edited by informer; 09-24-16 at 04:08.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •