[dbo].[InternationalBookingNumberAddress]
CREATE TABLE [dbo].[InternationalBookingNumberAddress]
(
[InternationalBookingNumberAddressID] [int] NOT NULL IDENTITY(1, 1),
[InternationalBookingNumberFID] [int] NOT NULL,
[Contact] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[AddressTypeFID] [int] NULL,
[Address1] [dbo].[Address] NULL,
[Address2] [dbo].[Address] NULL,
[Address3] [dbo].[Address] NULL,
[City] [dbo].[AddressCity] NULL,
[State] [dbo].[AddressState] NULL,
[PostalCode] [dbo].[AddressPostalCode] NULL,
[CountryCodeStandardFID] [int] NULL,
[Name] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[InternationalBookingNumberLocationTypeFID] [int] NULL,
[LocationCode] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[InternationalConsolidatorFID] [int] NULL,
[InternationalPortFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [CK_InternationalBookingNumberAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Return' OR [dbo].[GetAddressTypeName]([AddressTypeFID])='Pickup'))
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [PK_InternationalBookingNumberAddress] PRIMARY KEY CLUSTERED ([InternationalBookingNumberAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [IX_InternationalBookingNumberAddress_AddressType] UNIQUE NONCLUSTERED ([InternationalBookingNumberFID], [AddressTypeFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [FK_InternationalBookingNumberAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [FK_InternationalBookingNumberAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [FK_InternationalBookingNumberAddress_InternationalBookingNumber] FOREIGN KEY ([InternationalBookingNumberFID]) REFERENCES [dbo].[InternationalBookingNumber] ([InternationalBookingNumberID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [FK_InternationalBookingNumberAddress_InternationalBookingNumberLocationType] FOREIGN KEY ([InternationalBookingNumberLocationTypeFID]) REFERENCES [dbo].[InternationalBookingNumberLocationType] ([InternationalBookingNumberLocationTypeID])
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [FK_InternationalBookingNumberAddress_InternationalConsolidator] FOREIGN KEY ([InternationalConsolidatorFID]) REFERENCES [dbo].[InternationalConsolidator] ([InternationalConsolidatorID])
GO
ALTER TABLE [dbo].[InternationalBookingNumberAddress] ADD CONSTRAINT [FK_InternationalBookingNumberAddress_InternationalPort] FOREIGN KEY ([InternationalPortFID]) REFERENCES [dbo].[InternationalPort] ([InternationalPortID])
GO
GRANT SELECT ON [dbo].[InternationalBookingNumberAddress] TO [MssExec]
GRANT INSERT ON [dbo].[InternationalBookingNumberAddress] TO [MssExec]
GRANT DELETE ON [dbo].[InternationalBookingNumberAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[InternationalBookingNumberAddress] TO [MssExec]
GO