Hi, i have a table with order details. User is able to modify these details after he adds them for first time. My question is what is more right way to save prior to update changes. By that i mean not just subjective way of thinking but drawbacks in each way i list or maybe your suggestion...
I thought of creating Orders history table which will be identical to Orders so once i update an order, old one moves to HistoryOrders and this Order is updated.
Other way was to create new Order each time there is an update while using parent field in Order, ie. first Order has null as parentOrderID while update has prior to update orderID in parentOrderID column row...
I need later to work with that data so i need the most flexible solution... maybe i miss another option...
CREATE TABLE [dbo].[Orders](
[orderID] [int] IDENTITY(1,1) NOT NULL,
[userID] [int] NOT NULL,
[paymentMethodID] [tinyint] NOT NULL,
[orderAmount] [smallint] NOT NULL,
[orderStatusID] [tinyint] NOT NULL,
[date] [smalldatetime] NOT NULL,
CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED
(
[orderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Orders] WITH CHECK ADD CONSTRAINT [FK_Orders_Users] FOREIGN KEY([userID])
REFERENCES [dbo].[Users] ([userID])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Users]
GO
thanks