1
我有一個原始表:數據庫設計:兩個表相同的列,但不同的外鍵
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。
應該是什麼這些表進行正確的設計?