I use the EventInstance.RemoveDate as the "IsSoftDelete" flag.
If it is null, then I assume its legit, if it is populated, I assume it was
softdeleted.
This is 2 year old code, so don't ask too many detailed questions about it.
My soft delete "IsRemoved" case statement in sql server looks like this:
Select
--EventDefinitionID ,
EventDefinitionUUID ,
CAST(EDTS as int) as EDTS ,
EventDefinitionTypeUUID ,
EventDefinitionName ,
EventICalendarExpression ,
EventMasterStartTime ,
EventMasterEndTime ,
CreateDate ,
UpdateDate ,
LastInstanceUpdateDate ,
RemoveDate ,
'IsRemoved' =
CASE
WHEN RemoveDate IS NULL THEN 0
ELSE 1
END
From
dbo.EventDefinition ed
Here is my DDL. I can't help much beyond this, I never finished everything
myself.
if exists (select * from sysobjects
where id = object_id('EventInstance'))
DROP TABLE EventInstance
if exists (select * from sysobjects
where id = object_id('EventDefinition'))
DROP TABLE EventDefinition
if exists (select * from sysobjects
where id = object_id('EventDefinitionType'))
DROP TABLE EventDefinitionType
CREATE TABLE dbo.EventDefinitionType (
--EventDefinitionTypeID int IDENTITY (1,1) PRIMARY KEY NONCLUSTERED, --self
explanatory
EventDefinitionTypeUUID uniqueidentifier NOT NULL DEFAULT NEWID() PRIMARY
KEY NONCLUSTERED ,
EventDefinitionTypeName varchar(128) NOT NULL UNIQUE ,
CONSTRAINT edt_key UNIQUE ( EventDefinitionTypeUUID )
)
CREATE TABLE dbo.EventDefinition (
--EventDefinitionID int IDENTITY (1,1) PRIMARY KEY NONCLUSTERED, --self
explanatory
EventDefinitionUUID uniqueidentifier NOT NULL DEFAULT NEWID() PRIMARY KEY
NONCLUSTERED ,
EDTS timestamp null ,
EventDefinitionTypeUUID uniqueidentifier NOT NULL FOREIGN KEY
(EventDefinitionTypeUUID) REFERENCES
EventDefinitionType(EventDefinitionTypeUUID) DEFAULT
'00000000-0000-0000-0000-000000000000', --
EventDefinitionName varchar(128) NOT NULL UNIQUE ,
EventICalendarExpression varchar(1024) NULL , --NULL for manual entries
EventMasterStartTime varchar(24) NULL DEFAULT '00:00:00' ,
EventMasterEndTime varchar(24) NULL DEFAULT '00:00:00' ,
CreateDate datetime NOT NULL DEFAULT getDate(),
UpdateDate datetime NOT NULL DEFAULT getDate() ,
LastInstanceUpdateDate datetime NULL ,
RemoveDate datetime NULL ,
CONSTRAINT ed_key UNIQUE ( EventDefinitionUUID )
)
if exists (select * from sysobjects
where id = object_id('EventInstance'))
DROP TABLE EventInstance
CREATE TABLE dbo.EventInstance (
--EventInstanceID int IDENTITY (1,1) PRIMARY KEY NONCLUSTERED, --self
explanatory
EventInstanceUUID uniqueidentifier NOT NULL DEFAULT NEWID() PRIMARY KEY
NONCLUSTERED ,
EITS timestamp null ,
EventDefinitionUUID uniqueidentifier NOT NULL FOREIGN KEY
(EventDefinitionUUID) REFERENCES EventDefinition(EventDefinitionUUID), --
OccurenceDate datetime NOT NULL ,
EventInstanceStartTime varchar(24) NULL ,
EventInstanceEndTime varchar(24) NULL ,
Notes varchar(1024) NULL ,
ManualEntry bit NOT NULL DEFAULT 0 ,
CreateDate datetime NOT NULL DEFAULT getDate(),
UpdateDate datetime NOT NULL DEFAULT getDate() ,
RemoveDate datetime NULL ,
CONSTRAINT ei_key UNIQUE ( EventInstanceUUID )
)
GO
INSERT INTO dbo.EventDefinitionType ( EventDefinitionTypeUUID ,
EventDefinitionTypeName )
VALUES ( '00000000-0000-0000-0000-000000000000' , 'Unknown' )
INSERT INTO dbo.EventDefinitionType ( EventDefinitionTypeUUID ,
EventDefinitionTypeName )
VALUES ( '00000000-0000-0000-0000-000000000001' , 'No Rule' )
INSERT INTO dbo.EventDefinitionType ( EventDefinitionTypeUUID ,
EventDefinitionTypeName )
VALUES ( '00000000-0000-0000-0000-000000000002' , 'Simple Rule' )
INSERT INTO dbo.EventDefinitionType ( EventDefinitionTypeUUID ,
EventDefinitionTypeName )
VALUES ( '00000000-0000-0000-0000-000000000003' , 'Complex Rule' )
GO