[dbo].[QuickBooksItemCodeMap]
CREATE TABLE [dbo].[QuickBooksItemCodeMap]
(
[QuickBooksItemCodeMapID] [int] NOT NULL IDENTITY(1, 1),
[ItemCodeFID] [int] NOT NULL,
[RevenueItemFID] [int] NULL,
[CommissionExpenseFID] [int] NULL,
[ThirdPartyExpenseFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[QuickBooksItemCodeMap] ADD CONSTRAINT [PK_QuickBooksItemCodeMap] PRIMARY KEY NONCLUSTERED ([QuickBooksItemCodeMapID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[QuickBooksItemCodeMap] ADD CONSTRAINT [IX_QuickBooksItemCodeMap_ItemCode] UNIQUE NONCLUSTERED ([ItemCodeFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[QuickBooksItemCodeMap] ADD CONSTRAINT [FK_QuickBooksItemCodeMap_CommissionExpense] FOREIGN KEY ([CommissionExpenseFID]) REFERENCES [dbo].[QuickBooksExpenseAccount] ([QuickBooksExpenseAccountID])
GO
ALTER TABLE [dbo].[QuickBooksItemCodeMap] ADD CONSTRAINT [FK_QuickBooksItemCodeMap_ItemCode] FOREIGN KEY ([ItemCodeFID]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[QuickBooksItemCodeMap] ADD CONSTRAINT [FK_QuickBooksItemCodeMap_RevenueItem] FOREIGN KEY ([RevenueItemFID]) REFERENCES [dbo].[QuickBooksRevenueItem] ([QuickBooksRevenueItemID])
GO
ALTER TABLE [dbo].[QuickBooksItemCodeMap] ADD CONSTRAINT [FK_QuickBooksItemCodeMap_ThirdPartyExpense] FOREIGN KEY ([ThirdPartyExpenseFID]) REFERENCES [dbo].[QuickBooksExpenseAccount] ([QuickBooksExpenseAccountID])
GO
GRANT SELECT ON [dbo].[QuickBooksItemCodeMap] TO [MssExec]
GRANT INSERT ON [dbo].[QuickBooksItemCodeMap] TO [MssExec]
GRANT DELETE ON [dbo].[QuickBooksItemCodeMap] TO [MssExec]
GRANT UPDATE ON [dbo].[QuickBooksItemCodeMap] TO [MssExec]
GO