USE [EnVisage]
GO

if exists (select 1 from sys.foreign_keys where name like 'FK_Holiday2Team_Team')
begin
	ALTER TABLE [dbo].[Holiday2Team] DROP CONSTRAINT [FK_Holiday2Team_Team]
end
GO

if exists (select 1 from sys.foreign_keys where name like 'FK_Holiday2Team_Holiday')
begin
	ALTER TABLE [dbo].[Holiday2Team] DROP CONSTRAINT [FK_Holiday2Team_Holiday]
end
GO

if exists (select 1 from sys.default_constraints where name like 'DF_Holiday2Team_Id')
begin
	ALTER TABLE [dbo].[Holiday2Team] DROP CONSTRAINT [DF_Holiday2Team_Id]
end
GO

/****** Object:  Table [dbo].[Holiday2Team]    Script Date: 2/16/2016 6:44:49 PM ******/
if exists (select 1 from sys.tables where name like 'Holiday2Team')
begin
	DROP TABLE [dbo].[Holiday2Team]
end
GO

/****** Object:  Table [dbo].[Holiday2Team]    Script Date: 2/16/2016 6:44:49 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Holiday2Team](
	[Id] [uniqueidentifier] NOT NULL,
	[HolidayId] [uniqueidentifier] NOT NULL,
	[TeamId] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Holiday2Team] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Holiday2Team] ADD  CONSTRAINT [DF_Holiday2Team_Id]  DEFAULT (newid()) FOR [Id]
GO

ALTER TABLE [dbo].[Holiday2Team]  WITH CHECK ADD  CONSTRAINT [FK_Holiday2Team_Holiday] FOREIGN KEY([HolidayId])
REFERENCES [dbo].[Holiday] ([Id])
GO

ALTER TABLE [dbo].[Holiday2Team] CHECK CONSTRAINT [FK_Holiday2Team_Holiday]
GO

ALTER TABLE [dbo].[Holiday2Team]  WITH CHECK ADD  CONSTRAINT [FK_Holiday2Team_Team] FOREIGN KEY([TeamId])
REFERENCES [dbo].[Team] ([Id])
GO

ALTER TABLE [dbo].[Holiday2Team] CHECK CONSTRAINT [FK_Holiday2Team_Team]
GO


