
[dbo].[XLedgerItemCodeMap]
CREATE TABLE [dbo].[XLedgerItemCodeMap]
(
[XLedgerItemCodeMapId] [int] NOT NULL IDENTITY(1, 1),
[ItemCodeFid] [int] NOT NULL,
[AccountingAccountFid] [int] NOT NULL,
[XLedgerItemCodeMapAccountTypeFid] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XLedgerItemCodeMap] ADD CONSTRAINT [PK_XLedgerItemCodeMap] PRIMARY KEY CLUSTERED ([XLedgerItemCodeMapId]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XLedgerItemCodeMap] ADD CONSTRAINT [IX_XLedgerItemCodeMap_ItemCode_XLedgerItemCodeMapAccountType] UNIQUE NONCLUSTERED ([ItemCodeFid], [XLedgerItemCodeMapAccountTypeFid]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_XLedgerItemCodeMap_AccountingAccountFid] ON [dbo].[XLedgerItemCodeMap] ([AccountingAccountFid]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XLedgerItemCodeMap] ADD CONSTRAINT [FK_XLedgerItemCodeMap_AccountingAccount] FOREIGN KEY ([AccountingAccountFid]) REFERENCES [dbo].[AccountingAccount] ([AccountingAccountId])
GO
ALTER TABLE [dbo].[XLedgerItemCodeMap] ADD CONSTRAINT [FK_XLedgerItemCodeMap_ItemCode] FOREIGN KEY ([ItemCodeFid]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[XLedgerItemCodeMap] ADD CONSTRAINT [FK_XLedgerItemCodeMap_XLedgerItemCodeMapAccountType] FOREIGN KEY ([XLedgerItemCodeMapAccountTypeFid]) REFERENCES [dbo].[XLedgerItemCodeMapAccountType] ([XLedgerItemCodeMapAccountTypeId])
GO
GRANT SELECT ON [dbo].[XLedgerItemCodeMap] TO [MssExec]
GRANT INSERT ON [dbo].[XLedgerItemCodeMap] TO [MssExec]
GRANT DELETE ON [dbo].[XLedgerItemCodeMap] TO [MssExec]
GRANT UPDATE ON [dbo].[XLedgerItemCodeMap] TO [MssExec]
GO