use EnVisage

go
 

IF EXISTS (SELECT * FROM sys.tables where name='PeopleResourceActuals')
begin
DROP TABLE [dbo].[PeopleResourceActuals]
end

CREATE TABLE [dbo].[PeopleResourceActuals](
	[Id] [uniqueidentifier] NOT NULL,
	[PeopleResourceId] [uniqueidentifier] NOT NULL,
	[ParentId] [uniqueidentifier] NOT NULL,
	[Quantity]	[decimal](18,6) NOT NULL,
	[Cost]		[decimal](15,4) NOT NULL,
	[RowCreateDate] [datetime] NOT NULL,
 CONSTRAINT [PK_PeopleResourceActuals] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY],
 CONSTRAINT [UK_PeopleResourceActuals] UNIQUE NONCLUSTERED 
(
	[PeopleResourceId] ASC,
	[ParentId] ASC

	 
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]



ALTER TABLE [dbo].[PeopleResourceActuals] ADD  CONSTRAINT [DF_PeopleResourceActuals_Id]  DEFAULT (newid()) FOR [Id]


ALTER TABLE [dbo].[PeopleResourceActuals]  WITH CHECK ADD  CONSTRAINT [FK_PeopleResourceActuals_PeopleResource] FOREIGN KEY([PeopleResourceId])
REFERENCES [dbo].[PeopleResource] ([Id])


ALTER TABLE [dbo].[PeopleResourceActuals] CHECK CONSTRAINT [FK_PeopleResourceActuals_PeopleResource]


