在付款等多种选项的情况下,建立数据库关系的最佳方法是什么? [英] what is the best way to make database relation in case of multiple options like payment?

查看:58
本文介绍了在付款等多种选项的情况下,建立数据库关系的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在设计数据库关系时遇到了这个问题,我想知道最好的方法是什么。



我有客户可以付款,但他有很多选择支付,如现金,支票或信用卡。



基本上我有客户表(cust-id,cust-name ...)和付款选项表(opt-id),但每种付款方式都有不同的数据,也必须记录。数据将保存在与客户表有关系的订单表(order-id,order-date ...)中。



那么如何在数据库中进行这种关系?

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?

推荐答案

您可以将OptID添加到订单中表。 Order表中的OptID将引用PaymentOption表中的OptID。这将在PaymentOption和Order表之间创建一个关系,其中Order.OptID引用PaymentOption.OptID。



这是一个很好的例子,非常类似你想要的执行: https://technet.microsoft.com/en-us/ library / ms175464%28v = sql.105%29.aspx [ ^ ]
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[^]


您好,



查看以下内容...



您可以使用下表来维护表之间的关系

Hi,

Check below...

You can have below tables to maintain relations between your tables
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


这篇关于在付款等多种选项的情况下,建立数据库关系的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆