IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[Image]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[Image]
  (
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Picture] [image] NOT NULL,
    CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED 
    (
        [Id] ASC
    )
  ) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[ImageXTab]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[ImageXTab]
  (
    [FKFollowupNumber] [int] NOT NULL,
    [FKImageId] [int] NOT NULL,
    CONSTRAINT [PK_ImageXTab] PRIMARY KEY CLUSTERED 
    (
      [FKFollowupNumber] ASC,
      [FKImageId] ASC
    )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[ImageXTab]  WITH CHECK ADD  CONSTRAINT [FK_ImageXTab_FollowUp] FOREIGN KEY([FKFollowupNumber])
  REFERENCES [dbo].[FollowUp] ([FollowUpNumber])

  ALTER TABLE [dbo].[ImageXTab] CHECK CONSTRAINT [FK_ImageXTab_FollowUp]

  ALTER TABLE [dbo].[ImageXTab]  WITH CHECK ADD  CONSTRAINT [FK_ImageXTab_Image] FOREIGN KEY([FKImageId])
  REFERENCES [dbo].[Image] ([Id])

  ALTER TABLE [dbo].[ImageXTab] CHECK CONSTRAINT [FK_ImageXTab_Image]
END
