[dbo].[InternationalBookingNumberPhoneNumber]
CREATE TABLE [dbo].[InternationalBookingNumberPhoneNumber]
(
[InternationalBookingNumberPhoneNumberID] [int] NOT NULL IDENTITY(1, 1),
[InternationalBookingNumberFID] [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].[InternationalBookingNumberPhoneNumber] ADD CONSTRAINT [CK_InternationalBookingNumberPhoneNumber_PhoneType] CHECK (([dbo].[GetPhoneNumberTypeName]([PhoneTypeFID])='Return' OR [dbo].[GetPhoneNumberTypeName]([PhoneTypeFID])='Pickup' OR [dbo].[GetPhoneNumberTypeName]([PhoneTypeFID])='Transit'))
GO
ALTER TABLE [dbo].[InternationalBookingNumberPhoneNumber] ADD CONSTRAINT [PK_InternationalBookingNumberPhoneNumber] PRIMARY KEY NONCLUSTERED ([InternationalBookingNumberPhoneNumberID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalBookingNumberPhoneNumber] ADD CONSTRAINT [IX_InternationalBookingNumber_PhoneType] UNIQUE NONCLUSTERED ([InternationalBookingNumberFID], [PhoneTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalBookingNumberPhoneNumber] ADD CONSTRAINT [FK_InternationalBookingNumberPhoneNumber_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[InternationalBookingNumberPhoneNumber] ADD CONSTRAINT [FK_InternationalBookingNumberPhoneNumber_InternationalBookingNumber] FOREIGN KEY ([InternationalBookingNumberFID]) REFERENCES [dbo].[InternationalBookingNumber] ([InternationalBookingNumberID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[InternationalBookingNumberPhoneNumber] ADD CONSTRAINT [FK_InternationalBookingNumberPhoneNumber_PhoneType] FOREIGN KEY ([PhoneTypeFID]) REFERENCES [dbo].[PhoneType] ([PhoneTypeID])
GO
GRANT SELECT ON [dbo].[InternationalBookingNumberPhoneNumber] TO [MssExec]
GRANT INSERT ON [dbo].[InternationalBookingNumberPhoneNumber] TO [MssExec]
GRANT DELETE ON [dbo].[InternationalBookingNumberPhoneNumber] TO [MssExec]
GRANT UPDATE ON [dbo].[InternationalBookingNumberPhoneNumber] TO [MssExec]
GO