IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[WareAddon]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[WareAddon]
  (
    [FK_WareNumber] [int] NOT NULL,
    [FK_WareNumberRelated] [int] NOT NULL,
    [AddOnType] [smallint] NOT NULL,
    CONSTRAINT [PK_WareAddon] PRIMARY KEY CLUSTERED 
    (
      [FK_WareNumber] ASC,
      [FK_WareNumberRelated] ASC,
      [AddOnType] ASC
    )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[WareAddon]  WITH NOCHECK ADD  CONSTRAINT [FK_WareAddon_Ware] FOREIGN KEY([FK_WareNumber]) REFERENCES [dbo].[Ware] ([WareNumber])

  ALTER TABLE [dbo].[WareAddon] CHECK CONSTRAINT [FK_WareAddon_Ware]

  ALTER TABLE [dbo].[WareAddon]  WITH NOCHECK ADD  CONSTRAINT [FK_WareAddon_Ware1] FOREIGN KEY([FK_WareNumberRelated]) REFERENCES [dbo].[Ware] ([WareNumber])

  ALTER TABLE [dbo].[WareAddon] CHECK CONSTRAINT [FK_WareAddon_Ware1]
END