if not exists(select * from sys.tables t where t.[name] = 'T_EMPR_DETAILS_DEATH_CERTIFICATE')
CREATE TABLE [EMDR].[T_EMPR_DETAILS_DEATH_CERTIFICATE]
(
    [EmprDetailsID] uniqueidentifier NOT NULL,
    [DeathDateTime] datetime NOT NULL,
    [Series] varchar(255) NOT NULL,
    [Number] varchar(255) NOT NULL
)
ON [PRIMARY]
GO

if not exists(select * from sys.key_constraints kc where kc.name = 'PK_T_EMPR_DETAILS_DEATH_CERTIFICATE')
ALTER TABLE [EMDR].[T_EMPR_DETAILS_DEATH_CERTIFICATE] ADD CONSTRAINT [PK_T_EMPR_DETAILS_DEATH_CERTIFICATE]
PRIMARY KEY CLUSTERED ([EmprDetailsID]) ON [PRIMARY]
GO

if not exists(select * from sys.foreign_keys fk where fk.name = 'FK_T_EMPR_DETAILS_T_EMPR_DETAILS_DEATH_CERTIFICATE_EmprDetailsID')
ALTER TABLE [EMDR].[T_EMPR_DETAILS_DEATH_CERTIFICATE] ADD CONSTRAINT [FK_T_EMPR_DETAILS_T_EMPR_DETAILS_DEATH_CERTIFICATE_EmprDetailsID]
FOREIGN KEY([EmprDetailsID]) REFERENCES [EMDR].[T_EMPR_DETAILS] ([EmprDetailsID])
GO

