Suppose I have an object, with certain fields which I want to track history, and certain fields which I do not want to track history. From a normalization perspective, is the following schema alright:
CREATE TABLE MyObject AS (
MyObjectId INT IDENTITY NOT NULL PRIMARY KEY,
MyObjectField1 VARCHAR(100) NOT NULL,
MyObjectField2 VARCHAR(100) NOT NULL,
MyObjectField3 VARCHAR(100) NOT NULL,
MyObjectTrackedField1 VARCHAR(100) NOT NULL,
MyObjectTrackedField2 VARCHAR(100) NOT NULL,
MyObjectTrackedField3 VARCHAR(100) NOT NULL,
)
CREATE TABLE MyObjectHistory AS (
MyObjectHistoryId INT IDENTITY NOT NULL PRIMARY KEY,
MyObjectId INT NOT NULL FOREIGN KEY REFERENCES MyObject(MyObjectId),
MyObjectTrackedField1 VARCHAR(100) NOT NULL,
MyObjectTrackedField2 VARCHAR(100) NOT NULL,
MyObjectTrackedField3 VARCHAR(100) NOT NULL,
)
where MyObjectHistory contains the tracked fields for all except for the latest revision. Or, should all tracked fields be in one table, and all revisions including the latest be in that table, as in:
CREATE TABLE MyObject AS (
MyObjectId INT IDENTITY NOT NULL PRIMARY KEY,
MyObjectField1 VARCHAR(100) NOT NULL,
MyObjectField2 VARCHAR(100) NOT NULL,
MyObjectField3 VARCHAR(100) NOT NULL,
)
CREATE TABLE MyObjectHistory AS (
MyObjectHistoryId INT IDENTITY NOT NULL PRIMARY KEY,
MyObjectId INT NOT NULL FOREIGN KEY REFERENCES MyObject(MyObjectId),
MyObjectTrackedField1 VARCHAR(100) NOT NULL,
MyObjectTrackedField2 VARCHAR(100) NOT NULL,
MyObjectTrackedField3 VARCHAR(100) NOT NULL,
)