USE [EnVisage]
GO

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

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

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

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

/****** Object:  Table [dbo].[Holiday2PeopleResource]    Script Date: 2/16/2016 6:41:33 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Holiday2PeopleResource](
	[Id] [uniqueidentifier] NOT NULL,
	[HolidayId] [uniqueidentifier] NOT NULL,
	[ResourceId] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Holiday2PeopleResource] 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].[Holiday2PeopleResource] ADD  CONSTRAINT [DF_Holiday2PeopleResource_Id]  DEFAULT (newid()) FOR [Id]
GO

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

ALTER TABLE [dbo].[Holiday2PeopleResource] CHECK CONSTRAINT [FK_Holiday2PeopleResource_Holiday]
GO

ALTER TABLE [dbo].[Holiday2PeopleResource]  WITH CHECK ADD  CONSTRAINT [FK_Holiday2PeopleResource_PeopleResource] FOREIGN KEY([ResourceId])
REFERENCES [dbo].[PeopleResource] ([Id])
GO

ALTER TABLE [dbo].[Holiday2PeopleResource] CHECK CONSTRAINT [FK_Holiday2PeopleResource_PeopleResource]
GO


