我有一个原始表:
CREATE TABLE [dbo].[tblSalesOrderPayment]
(
[PaymentID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[SalesOrderID] [int] NOT NULL,
[PaymentType] [int] NOT NULL,
[AmountPaid] [decimal](18, 2) NOT NULL,
[AmountTendered] [decimal](18, 2) NOT NULL,
[PaymentDate] [datetime] NOT NULL,
[Cashier] [int] NOT NULL,
[PaymentStatus] [bit] NOT NULL
)
..我设计了另一张这样的桌子
CREATE TABLE [dbo].[tblReturnOrderPayment]
(
[PaymentID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[ReturnOrderID] [int] NOT NULL,
[PaymentType] [tinyint] NOT NULL,
[AmountPaid] [decimal](18, 2) NOT NULL,
[AmountTendered] [decimal](18, 2) NOT NULL,
[PaymentDate] [datetime] NOT NULL,
[Cashier] [int] NOT NULL,
[PaymentStatus] [bit] NOT NULL
)
.. 如您所见,它具有相同数量的列和类型,但它们具有不同的外键。tblSalesOrderPayment 具有来自 tblSalesOrder 的 SalesOrderID,并且 tblReturnOrderPayment 具有来自 tblReturnOrder 的 ReturnOrderID。
- 一旦销售订单已经退回,所有付款明细都应该转移到 tblReturnOrderPayment,但我需要保留 tblSalesOrderPayment 的记录以供参考。
- 一旦销售订单退回,未来的付款将保存到 tblReturnOrderPayment。
这些桌子的正确设计应该是什么?