EnVisageOnline/Main/Database/Schema/Tables/dbo.Team.sql

26 lines
2.4 KiB
Transact-SQL
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
Run this script on SQL Server 2008 or later. There may be flaws if running on earlier versions of SQL Server.
*/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Team]') AND type in (N'U'))
DROP TABLE [dbo].[Team]
GO
CREATE TABLE [dbo].[Team] (
[Id] [uniqueidentifier] NOT NULL,
[Name] [nchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CompanyId] [uniqueidentifier] NULL,
[OwnerId] [uniqueidentifier] NULL,
[CostCenterId] [uniqueidentifier] NULL,
[GLDepartmentId] [uniqueidentifier] NULL,
[ReportsTo] [uniqueidentifier] NULL,
CONSTRAINT [PK_Team] PRIMARY KEY CLUSTERED ([Id])
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Team] ADD CONSTRAINT [FK_Team_Company] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Company] ([Id])
GO
ALTER TABLE [dbo].[Team] ADD CONSTRAINT [FK_Team_Contact] FOREIGN KEY ([ReportsTo]) REFERENCES [dbo].[Contact] ([Id])
GO
ALTER TABLE [dbo].[Team] ADD CONSTRAINT [FK_Team_CreditDepartment] FOREIGN KEY ([CostCenterId]) REFERENCES [dbo].[CreditDepartment] ([Id])
GO
ALTER TABLE [dbo].[Team] ADD CONSTRAINT [FK_Team_GLDepartment] FOREIGN KEY ([GLDepartmentId]) REFERENCES [dbo].[GLDepartment] ([Id])
GO