Advertisement

11.14.2008 at 04:20AM PST, ID: 23904923
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.9

Row versioning data inside a table

Asked by noel58 in Data Manipulation, Databases Miscellaneous, MS SQL Server

Tags: ,

Hi guys,

Loooking for view / opinions on the following ( got a debate with someone so thought Id ask everyone here)...

Im going to comapre two ways in which i can see i could version groups of data within a table.

The business need here is that we have forms that have fields which contains values from lookup fields. We are basically creating a table for lookup fields, the requirement is that we should be able to see the easily version these lookups. so when one or more values change we create a new version of our available lookup fields.

Consider the following two tables...

CREATE TABLE [dbo].[Method1](
    [TypeID] [int] IDENTITY(1,1) NOT NULL,
    [TypeName] [nvarchar](100) NOT NULL,
    [Version] [int] NOT NULL,
    [Value] [nvarchar](100) NOT NULL
)

CREATE TABLE [dbo].[Method2](
    [TypeID] [int] IDENTITY(1,1) NOT NULL,
    [TypeName] [nvarchar](100) NOT NULL,
    [ValueID] [int] NOT NULL,
    [Value] [nvarchar](100) NOT NULL,
    [Deleted] [bit] NOT NULL
)

Now in table Method1 data will look like this....

TypeID TypeName Version Value
------- ----------- ---------- -------------------------------------
1      Type 1       1        Some Value 1
2      Type 1       1        Some Value 2
3      Type 2       1        Some Value 1
4      Type 2       1        Some Value 2

To add / remove or even edit values of a given TypeName you create a new version of my TypeName

ie...

TypeID TypeName Version Value
------- ----------- ---------- -------------------------------------
1       Type 1       1       Some Value 1
2       Type 1       1       Some Value 2
5       Type 1       2       Some Value 1
6       Type 1       2       Some Value 2
7       Type 1       2       Some Value 3
3       Type 2       1       Some Value 1
4       Type 2       1       Some Value 2

I kinda see method one as explicitly saying this is my TypeName, i.e. these are its versions and these are its values.

Method2 data looks like this....

TypeID TypeName ValueID Value Deleted
-------- ------------ ---------- --------- ---------
1       Type 1       1       Value 1       0
2       Type 1       2       Value 2       0
3       Type 2       1       Value 1       0
4       Type 2       2       Value 2       0

To add data - create a new row of a given type and new value id

TypeID TypeName ValueID Value Deleted
-------- ------------ ---------- --------- ---------
1       Type 1       1       Value 1       0
2       Type 1       2       Value 2       0
3       Type 2       1       Value 1       0
4       Type 2       2       Value 2       0
5       Type 1       3       Value 3       0

To edit data - create a new row of a given type and reuse the value id

TypeID TypeName ValueID Value Deleted
 -------- ------------ ---------- --------- ---------
1       Type 1       1       Value 1       0
2       Type 1       2       Value 2       0
3       Type 2       1       Value 1       0
4       Type 2       2       Value 2       0
5       Type 1       1       Value 1a      0

To remove data - inset the type name again and mark as deleted

TypeID TypeName ValueID Value Deleted
-------- ------------ ---------- --------- ---------
1       Type 1       1       Value 1       0
2       Type 1       2       Value 2       0
3       Type 2       1       Value 1       0
4       Type 2       2       Value 2       0
5       Type 1       1       Value 1       1

Now i see method two (for better or worse at this stage) as kinda implicit versioning in that you having to rely on the developer knowing that the max type id for typname / valueid pair is the most recent value.

As much as i dislike duplicating data I cant help but feel method one is easier to understand and has benefits in making it easier to report on.

What are peoples views on how to keep versions of groups of data in the table (based on these examples or other methods).

Views much appreciated.Start Free Trial
[+][-]11.14.2008 at 06:16AM PST, ID: 22959631

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 06:33AM PST, ID: 22959757

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 07:14AM PST, ID: 22960160

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 07:37AM PST, ID: 22960418

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 08:00AM PST, ID: 22960698

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 10:59AM PST, ID: 22962441

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Data Manipulation, Databases Miscellaneous, MS SQL Server
Tags: SQL, Database design
Sign Up Now!
Solution Provided By: Sharath_123
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628