CREATE TABLE [dbo].[ToDoNote]
(
[ToDoNoteID] [int] NOT NULL IDENTITY(1, 1),
[ToDoFID] [int] NOT NULL,
[ChangedBySysuserFID] [int] NULL,
[ChangedDateTime] [datetime] NULL,
[Notes] [varchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[ToDoNote] ADD CONSTRAINT [PK_ToDoNote] PRIMARY KEY CLUSTERED ([ToDoNoteID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ToDoNote_ChangedBySysuserFID] ON [dbo].[ToDoNote] ([ChangedBySysuserFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ToDoNote_ToDoFID] ON [dbo].[ToDoNote] ([ToDoFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ToDoNote] ADD CONSTRAINT [FK_ToDoNote_Sysuser] FOREIGN KEY ([ChangedBySysuserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[ToDoNote] ADD CONSTRAINT [FK_ToDoNote_ToDo] FOREIGN KEY ([ToDoFID]) REFERENCES [dbo].[ToDo] ([ToDoID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[ToDoNote] TO [MssExec]
GRANT INSERT ON [dbo].[ToDoNote] TO [MssExec]
GRANT DELETE ON [dbo].[ToDoNote] TO [MssExec]
GRANT UPDATE ON [dbo].[ToDoNote] TO [MssExec]
GO