[dbo].[MilitaryBaseAddress]
CREATE TABLE [dbo].[MilitaryBaseAddress]
(
[MilitaryBaseAddressID] [int] NOT NULL IDENTITY(1, 1),
[MilitaryBaseFID] [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].[MilitaryBaseAddress] ADD CONSTRAINT [CK_MilitaryBaseAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[MilitaryBaseAddress] ADD CONSTRAINT [PK_MilitaryBaseAddress] PRIMARY KEY NONCLUSTERED ([MilitaryBaseAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryBaseAddress] ADD CONSTRAINT [IX_MilitaryBaseAddress_AddressType] UNIQUE NONCLUSTERED ([MilitaryBaseFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryBaseAddress] ADD CONSTRAINT [FK_MilitaryBaseAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[MilitaryBaseAddress] ADD CONSTRAINT [FK_MilitaryBaseAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[MilitaryBaseAddress] ADD CONSTRAINT [FK_MilitaryBaseAddress_MilitaryBase] FOREIGN KEY ([MilitaryBaseFID]) REFERENCES [dbo].[MilitaryBase] ([MilitaryBaseID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[MilitaryBaseAddress] TO [MssExec]
GRANT INSERT ON [dbo].[MilitaryBaseAddress] TO [MssExec]
GRANT DELETE ON [dbo].[MilitaryBaseAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[MilitaryBaseAddress] TO [MssExec]
GO