IF NOT EXISTS(SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.OTARateAmountNotifLog') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[OTARateAmountNotifLog]
  (
    [DateStamp] [datetime] NOT NULL,
    [FKRateLevelChannelId] [int] NOT NULL,
    [FKProductNumber] [int] NOT NULL,
    [FKRoomTypeNumber] [int] NOT NULL,
    [RoomPrice] [money] NOT NULL,
    [SubmitDateStamp] [datetime] NOT NULL,
    CONSTRAINT [PK_OTARateAmountNotifLog] PRIMARY KEY CLUSTERED 
    (
      [DateStamp] ASC,
      [FKRateLevelChannelId] ASC,
      [FKProductNumber] ASC,
      [FKRoomTypeNumber] ASC
    )
  ) ON [PRIMARY]

  ALTER TABLE [dbo].[OTARateAmountNotifLog]  WITH CHECK ADD  CONSTRAINT [FK_OTARateAmountNotifLog_Products] FOREIGN KEY([FKProductNumber])
  REFERENCES [dbo].[Products] ([ProductNumber])

  ALTER TABLE [dbo].[OTARateAmountNotifLog] CHECK CONSTRAINT [FK_OTARateAmountNotifLog_Products]

  ALTER TABLE [dbo].[OTARateAmountNotifLog]  WITH CHECK ADD  CONSTRAINT [FK_OTARateAmountNotifLog_RateLevelChannel] FOREIGN KEY([FKRateLevelChannelId])
  REFERENCES [dbo].[RateLevelChannel] ([RateLevelChannelId])

  ALTER TABLE [dbo].[OTARateAmountNotifLog] CHECK CONSTRAINT [FK_OTARateAmountNotifLog_RateLevelChannel]

  ALTER TABLE [dbo].[OTARateAmountNotifLog]  WITH CHECK ADD  CONSTRAINT [FK_OTARateAmountNotifLog_RoomTypes] FOREIGN KEY([FKRoomTypeNumber])
  REFERENCES [dbo].[RoomTypes] ([RoomTypeNumber])

  ALTER TABLE [dbo].[OTARateAmountNotifLog] CHECK CONSTRAINT [FK_OTARateAmountNotifLog_RoomTypes]
END