[dbo].[MilitaryBaseContactAddress]
CREATE TABLE [dbo].[MilitaryBaseContactAddress]
(
[MilitaryBaseContactAddressID] [int] NOT NULL IDENTITY(1, 1),
[MilitaryBaseContactFID] [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].[MilitaryBaseContactAddress] ADD CONSTRAINT [CK_MilitaryBaseContactAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[MilitaryBaseContactAddress] ADD CONSTRAINT [PK_MilitaryBaseContactAddress] PRIMARY KEY NONCLUSTERED ([MilitaryBaseContactAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryBaseContactAddress] ADD CONSTRAINT [IX_MilitaryBaseContactAddress_AddressType] UNIQUE NONCLUSTERED ([MilitaryBaseContactFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryBaseContactAddress] ADD CONSTRAINT [FK_MilitaryBaseContactAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[MilitaryBaseContactAddress] ADD CONSTRAINT [FK_MilitaryBaseContactAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[MilitaryBaseContactAddress] ADD CONSTRAINT [FK_MilitaryBaseContactAddress_MilitaryBaseContact] FOREIGN KEY ([MilitaryBaseContactFID]) REFERENCES [dbo].[MilitaryBaseContact] ([MilitaryBaseContactID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[MilitaryBaseContactAddress] TO [MssExec]
GRANT INSERT ON [dbo].[MilitaryBaseContactAddress] TO [MssExec]
GRANT DELETE ON [dbo].[MilitaryBaseContactAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[MilitaryBaseContactAddress] TO [MssExec]
GO