Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 868057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:04:45+00:00 2026-05-15T10:04:45+00:00

i have a table with order details. User is able to modify these details

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:04:45+00:00Added an answer on May 15, 2026 at 10:04 am

    This gets more complex when you have multiple tables involved (parent/child), but when working with a single history table, the I general pattern that I use is to create two tables, the main one: XYZ and history one: XYZ_History. I have a single insert/update/delete trigger that copies all versions into the XYZ_History table. The XYZ_History table has all columns from the XYZ table including a XYZHistoryID int identity PK, XYZHistoryType char(1) “I”nsert, “U”pdate, “D”elete, and an XYZHistoryDate datetime column, which is GETDATE(). If I need to FK a value that is the “current” XYZ value I FK to XYZ.PK, if I need to FK a point in time, I use XYZ_History.XYZHistoryID. I also have a UPDATE/DELETE trigger on XYZ_History that issues a error that you can’t change the history.

    it is difficult to provide any specific advise without knowing your table structure more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of records in mySql. I need to maintain an order
In MS Transact SQL, let's say I have a table (Orders) like this: Order
For example, in my WCF, if I have a Customer table and an Order
I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int
I have table with 50 entries (users with such details like Name Surname Location
I have an order table with the following columns: orderid, clientid, [columns for order
I have one table orders with a foreing key ProductID. I want to show
I have two Tables. Order - With Columns OrderID, OrderStatusID OrderStatus - With Columns
Suppose I have a dataset with those two immortal tables: Employee & Order Emp
I have table inside a div tab. The table has 40 rows in it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.