CREATE TABLE [dbo].[BranchDivision]
(
[BranchDivisionID] [int] NOT NULL IDENTITY(1, 1),
[BranchFID] [int] NOT NULL,
[DivisionFID] [int] NOT NULL,
[BranchDefault] [bit] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[BranchDivision] ADD CONSTRAINT [CK_BranchDivision_BranchDefault] CHECK (((1)<>[dbo].[BranchDefaultDivisionExists]([BranchFID],[DivisionFID],[BranchDefault])))
GO
ALTER TABLE [dbo].[BranchDivision] ADD CONSTRAINT [PK_BranchDivision] PRIMARY KEY CLUSTERED ([BranchDivisionID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[BranchDivision] ADD CONSTRAINT [IX_Unique_BranchFID_DivisionFID] UNIQUE NONCLUSTERED ([BranchFID], [DivisionFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[BranchDivision] ADD CONSTRAINT [FK_BranchDivision_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[BranchDivision] ADD CONSTRAINT [FK_BranchDivision_Division] FOREIGN KEY ([DivisionFID]) REFERENCES [dbo].[Division] ([DivisionID])
GO
GRANT SELECT ON [dbo].[BranchDivision] TO [MssExec]
GRANT INSERT ON [dbo].[BranchDivision] TO [MssExec]
GRANT DELETE ON [dbo].[BranchDivision] TO [MssExec]
GRANT UPDATE ON [dbo].[BranchDivision] TO [MssExec]
GO