CREATE TABLE [dbo].[ATLink] (
    [ProcessID]   INT            NOT NULL,
    [FromEventID] INT            NOT NULL,
    [ToEventID]   INT            NOT NULL,
    [LinkStyle]   NVARCHAR (255) NULL,
    [Label]       NVARCHAR (255) NULL,
    [LabelStyle]  NVARCHAR (255) NULL,
    CONSTRAINT [PK_Link] PRIMARY KEY NONCLUSTERED ([ProcessID] ASC, [FromEventID] ASC, [ToEventID] ASC),
    CONSTRAINT [ATLink_FK1] FOREIGN KEY ([ProcessID]) REFERENCES [dbo].[ATProcessDefinition] ([ProcessID]),
    CONSTRAINT [ATLink_FK2] FOREIGN KEY ([FromEventID]) REFERENCES [dbo].[ATEventDefinition] ([EventID]),
    CONSTRAINT [ATLink_FK3] FOREIGN KEY ([ToEventID]) REFERENCES [dbo].[ATEventDefinition] ([EventID])
);


GO
CREATE NONCLUSTERED INDEX [ATLink_IX_FromEventId]
    ON [dbo].[ATLink]([FromEventID] ASC);


GO
CREATE NONCLUSTERED INDEX [ATLink_IX_ToEventId]
    ON [dbo].[ATLink]([ToEventID] ASC);

