IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[TransactionTransactionXtab]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[TransactionTransactionXtab]
  (
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [FK_TransactionNumber1] [int] NOT NULL,
    [FK_TransactionNumber2] [int] NOT NULL,
    [RelationType] [tinyint] NOT NULL,
    CONSTRAINT [PK_TransactionTransactionXtab_1] PRIMARY KEY CLUSTERED 
    (
      [Id] ASC
    )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[TransactionTransactionXtab]  WITH NOCHECK ADD  CONSTRAINT [FK_TransactionTransactionXtab_Transactions] FOREIGN KEY([FK_TransactionNumber1])
  REFERENCES [dbo].[Transactions] ([TransactionNumber])
  ON DELETE CASCADE

  ALTER TABLE [dbo].[TransactionTransactionXtab] CHECK CONSTRAINT [FK_TransactionTransactionXtab_Transactions]

  ALTER TABLE [dbo].[TransactionTransactionXtab]  WITH NOCHECK ADD  CONSTRAINT [FK_TransactionTransactionXtab_Transactions1] FOREIGN KEY([FK_TransactionNumber2])
  REFERENCES [dbo].[Transactions] ([TransactionNumber])

  ALTER TABLE [dbo].[TransactionTransactionXtab] CHECK CONSTRAINT [FK_TransactionTransactionXtab_Transactions1]
END