[dbo].[InternationalCustomsAgentPhoneNumber]
CREATE TABLE [dbo].[InternationalCustomsAgentPhoneNumber]
(
[InternationalCustomsAgentPhoneNumberID] [int] NOT NULL IDENTITY(1, 1),
[InternationalCustomsAgentFID] [int] NOT NULL,
[PhoneTypeFID] [int] NOT NULL,
[CountryCodeStandardFID] [int] NULL,
[AreaCode] [dbo].[PhoneAreaCode] NULL,
[LocalNumber] [dbo].[PhoneLocalNumber] NULL,
[Extension] [dbo].[PhoneExtension] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalCustomsAgentPhoneNumber] ADD CONSTRAINT [CK_InternationalCustomsAgentPhoneNumber_PhoneType] CHECK (([dbo].[GetPhoneNumberTypeName]([PhoneTypeFID])='Fax' OR [dbo].[GetPhoneNumberTypeName]([PhoneTypeFID])='Main'))
GO
ALTER TABLE [dbo].[InternationalCustomsAgentPhoneNumber] ADD CONSTRAINT [PK_InternationalCustomsAgentPhoneNumber] PRIMARY KEY NONCLUSTERED ([InternationalCustomsAgentPhoneNumberID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalCustomsAgentPhoneNumber] ADD CONSTRAINT [IX_InternationalCustomsAgent_PhoneType] UNIQUE NONCLUSTERED ([InternationalCustomsAgentFID], [PhoneTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalCustomsAgentPhoneNumber] ADD CONSTRAINT [FK_InternationalCustomsAgentPhoneNumber_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[InternationalCustomsAgentPhoneNumber] ADD CONSTRAINT [FK_InternationalCustomsAgentPhoneNumber_InternationalCustomsAgent] FOREIGN KEY ([InternationalCustomsAgentFID]) REFERENCES [dbo].[InternationalCustomsAgent] ([InternationalCustomsAgentID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[InternationalCustomsAgentPhoneNumber] ADD CONSTRAINT [FK_InternationalCustomsAgentPhoneNumber_PhoneType] FOREIGN KEY ([PhoneTypeFID]) REFERENCES [dbo].[PhoneType] ([PhoneTypeID])
GO
GRANT SELECT ON [dbo].[InternationalCustomsAgentPhoneNumber] TO [MssExec]
GRANT INSERT ON [dbo].[InternationalCustomsAgentPhoneNumber] TO [MssExec]
GRANT DELETE ON [dbo].[InternationalCustomsAgentPhoneNumber] TO [MssExec]
GRANT UPDATE ON [dbo].[InternationalCustomsAgentPhoneNumber] TO [MssExec]
GO