1

I have an application that allows my users to make temporary changes to an ongoing booking. I have recenlty read about the new XML datatype in SQL server, and the corresponding SqlXml type.

I am thinking of using the new type to store the previous values of the object so that I can later revert to them.

Something like:

Booking Table:

BookingID int
SomeField1 String
SomeField2 String
SomeField3 String
RevertValues XML
RevertDateTime DateTime2

This is a cut down version of my table, but I plan to store the current values in the ReverValues column and then revert when the RevertDatetime is reached.

My application uses a SQL Server 2008 database, Linq-to-SQL model, with a MVC front end.

Any and all advice would be appreciated as I've never done anything like this before!

Thanks

1 Answer 1

2

Sounds like a good idea to me - I'm doing similar things in SQL Server auditing where I keep audit entries in a table, along with two XML fields - ValuesBefore and ValuesAfter - to document and track changes.

What you might want to do is split out the "RevertValues" into a separate table that has a foreign key relationship to your bookings, so that you could keep track of several revisions of the booking - something like a BookingHistory table:

BookingHistory

BookingID            INT   (FK to Booking table)
DateOfModification   DATETIME
BookingData          XML

or something along those lines.

Marc

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Marc. How to you store/extract your object in the column? Serialise/Deserialise methods? Maybe put xml attributes in my partial class?
In my case, I simply serialize the object in question to XML and store that. Works fine. I wouldn't store that in your object - but provide a method on the class to render the class contents as XML (return a string)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.