CREATE TABLE [dbo].[ATQueue] (
    [Id]          INT              NOT NULL IDENTITY(1,1),
    [Queue]       NVARCHAR (32)    NOT NULL,
    [EventId]     INT              NOT NULL,
    [ProcessId]   INT              NOT NULL,
    [Description] NVARCHAR (255)   NULL,
    [SortType]    INT              NOT NULL,
    [Type]        INT              NOT NULL,
    [Alias]       NVARCHAR (255)   NULL,
    [ObjectId]    UNIQUEIDENTIFIER NOT NULL,
    [Signable]    BIT              NOT NULL DEFAULT 0,
    CONSTRAINT [PK_Queue] PRIMARY KEY NONCLUSTERED ([Id] ASC),
    CONSTRAINT [UK_Queue_ProcessId] UNIQUE ([Queue], [ProcessId]),
    CONSTRAINT [FK_ATQueue_ATEvent] FOREIGN KEY ([EventID]) REFERENCES [dbo].[ATEventDefinition] ([EventId]),
    CONSTRAINT [FK_ATQueue_ATProcessDefinition] FOREIGN KEY ([ProcessID]) REFERENCES [dbo].[ATProcessDefinition] ([ProcessId])
);

GO
CREATE NONCLUSTERED INDEX [ATQueue_IX_Queue]
    ON [dbo].[ATQueue]([Queue] ASC);

GO
CREATE NONCLUSTERED INDEX [ATQueue_IX_EventId]
    ON [dbo].[ATQueue]([EventId] ASC);

GO
CREATE NONCLUSTERED INDEX [ATQueue_IX_ProcessId]
    ON [dbo].[ATQueue]([ProcessId] ASC);

GO
CREATE NONCLUSTERED INDEX [ATQueue_ObjectID]
    ON [dbo].[ATQueue]([ObjectId] ASC);

