CREATE TABLE [dbo].[ATInboxEvent] (
    [Id]                 INT             NOT NULL IDENTITY (1,1),
    [InboxAssignment]    NVARCHAR(32)    NULL,
    [EventID]            INT             NOT NULL,
    [InboxId]            INT             NULL,
    [AssignmentTypeId]   INT             NOT NULL DEFAULT 0,
    CONSTRAINT [PK_ATInboxEvent] PRIMARY KEY CLUSTERED ([Id]),
    CONSTRAINT [FK_ATInboxEvent_ATEventDefinition] FOREIGN KEY ([EventID]) REFERENCES [dbo].[ATEventDefinition] ([EventID]),
    CONSTRAINT [FK_ATInboxEvent_ATQueue] FOREIGN KEY ([InboxId]) REFERENCES [dbo].[ATQueue] ([Id]),
    CONSTRAINT [FK_ATInboxEvent_ATAssignmentType] FOREIGN KEY ([AssignmentTypeId]) REFERENCES [dbo].[ATAssigmentType] ([Id])
);
GO;

CREATE NONCLUSTERED INDEX [IX_ATInboxEvent_EventID]
    ON [dbo].[ATInboxEvent] ([EventID]);

GO;

CREATE NONCLUSTERED INDEX [IX_ATInboxEvent_Inbox]
    ON [dbo].[ATInboxEvent] ([InboxId]);
