[dbo].[MilitaryCarrierContactAddress]
CREATE TABLE [dbo].[MilitaryCarrierContactAddress]
(
[MilitaryCarrierContactAddressID] [int] NOT NULL IDENTITY(1, 1),
[MilitaryCarrierContactFID] [int] NOT 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
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryCarrierContactAddress] ADD CONSTRAINT [CK_MilitaryCarrierContactAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[MilitaryCarrierContactAddress] ADD CONSTRAINT [PK_MilitaryCarrierContactAddress] PRIMARY KEY NONCLUSTERED ([MilitaryCarrierContactAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryCarrierContactAddress] ADD CONSTRAINT [IX_MilitaryCarrierContactAddress_AddressType] UNIQUE NONCLUSTERED ([MilitaryCarrierContactFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryCarrierContactAddress] ADD CONSTRAINT [FK_MilitaryCarrierContactAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[MilitaryCarrierContactAddress] ADD CONSTRAINT [FK_MilitaryCarrierContactAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[MilitaryCarrierContactAddress] ADD CONSTRAINT [FK_MilitaryCarrierContactAddress_MilitaryCarrierContact] FOREIGN KEY ([MilitaryCarrierContactFID]) REFERENCES [dbo].[MilitaryCarrierContact] ([MilitaryCarrierContactID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[MilitaryCarrierContactAddress] TO [MssExec]
GRANT INSERT ON [dbo].[MilitaryCarrierContactAddress] TO [MssExec]
GRANT DELETE ON [dbo].[MilitaryCarrierContactAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[MilitaryCarrierContactAddress] TO [MssExec]
GO