Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to know how should i store the foreign key in order_item table so that it identifies the order and estimate/invoice/purchaseorder it belongs too.

What I have tried:

table name: order relates to (contact, estimate, invoice, shipment) tables.
column name: contact_id (foreign key(referring to id column of the contact table)).
column name: estimate_id (foreign key(referring to id column of the estimate table)).
column name: invoice_id (foreign key(referring to id column of the invoice table)).
column name: shipment_id (foreign key(referring to id column of the shipment table)).

tablename: purchaseorder (this have one to many relationship with order table)
column name: order_id (foreign key(referring to id column of the order table)).
column name: contact_id (foreign key(referring to id column of the contact table)).
Posted
Updated 3-Feb-17 1:46am

1 solution

The answers lie with the user requirements. Analyse the requirements, identify the entities, their data attributes, and establish their relationships. Based on the analysis, design the database scheme for your application. Learn:
1. Introduction to database design[^]
2. 1NF, 2NF, 3NF and BCNF in Database Normalization | DBMS Tutorial | Studytonight[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900