IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[KitchenNoteDepartmentXTab]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE dbo.[KitchenNoteDepartmentXTab] (
    [FkKitchenNote] Int NOT NULL,
    [FkDepartment] smallint NOT NULL
    CONSTRAINT [PK_KitchenNoteDepartmentXTab] PRIMARY KEY CLUSTERED
    (
      [FkKitchenNote] ASC,
      [FkDepartment] ASC
    )
    ) ON [Primary]
  ALTER TABLE KitchenNoteDepartmentXTab WITH NOCHECK ADD CONSTRAINT FK_KitchenNoteDepartmentXTab_KitchenNote FOREIGN KEY (FkKitchenNote) REFERENCES KitchenNote (KitchenNoteNumber) ON DELETE CASCADE ON UPDATE CASCADE
  ALTER TABLE KitchenNoteDepartmentXTab WITH NOCHECK ADD CONSTRAINT FK_KitchenNoteDepartmentXTab_Departments FOREIGN KEY (FkDepartment) REFERENCES Departments (PK_Department) ON DELETE CASCADE ON UPDATE CASCADE
END