Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have this problem in designing database relation, and I want to know what is the best way to do this.

I have customer who can make payment, but he have many options to pay like cash, cheque, or by credit.

Basically I have customer table (cust-id, cust-name ...) and payment option table (opt-id) but each payment method have different data which must be recorded too. The data will be saved in order table (order-id, order-date ...) which have relation with customer table.

So how to do this relation in database?
Posted

You can add the OptID to the Order table. The OptID in the Order table will reference the OptID in the PaymentOption table. This will create a relationship between PaymentOption and Order tables, where Order.OptID references PaymentOption.OptID.

Here is a good example that is very similar what you are wanting to do: https://technet.microsoft.com/en-us/library/ms175464%28v=sql.105%29.aspx[^]
 
Share this answer
 
Hi,

Check below...

You can have below tables to maintain relations between your tables
SQL
Customer Table
----------------
Customer_Info
(
Cust_Id,
Cust_name,
.--Your Required Columns
.
.
)

Payment Option Table
--------------------
Pay_Option
(
Po_Id,
PO_Desc,
.--Your Required Columns
.
.
)

Payment Transaction Table
-------------------------
Payment_Trans
(
PT_Id,
PT_PO_Id,--from Payment Option tables
PT_Cust_Id,--from Customer table
PT_Amt,
PT_Status,
PT_Desc,
PT_Date,
.--Your Required Columns (with all required details of different payments)
.
.
)

Order Details Table
-------------------
Order_Dtls
(
Ord_Id,
Ord_PT_Id,--from payment Trans table
Ord_Cust_Id,--from customer table
Ord_Date,
.--Your Required Columns
.
.
)



Hope this will help you.

Cheers
 
Share this answer
 

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