[dbo].[ManufacturerAddress]
CREATE TABLE [dbo].[ManufacturerAddress]
(
[ManufacturerAddressID] [int] NOT NULL IDENTITY(1, 1),
[ManufacturerFID] [int] NOT NULL,
[AddressTypeFID] [int] NOT 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].[ManufacturerAddress] ADD CONSTRAINT [CK_ManufacturerAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[ManufacturerAddress] ADD CONSTRAINT [PK_ManufacturerAddress] PRIMARY KEY NONCLUSTERED ([ManufacturerAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ManufacturerAddress] ADD CONSTRAINT [IX_ManufacturerAddress_AddressType] UNIQUE NONCLUSTERED ([ManufacturerFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ManufacturerAddress] ADD CONSTRAINT [FK_ManufacturerAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[ManufacturerAddress] ADD CONSTRAINT [FK_ManufacturerAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[ManufacturerAddress] ADD CONSTRAINT [FK_ManufacturerAddress_Manufacturer] FOREIGN KEY ([ManufacturerFID]) REFERENCES [dbo].[Manufacturer] ([ManufacturerID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[ManufacturerAddress] TO [MssExec]
GRANT INSERT ON [dbo].[ManufacturerAddress] TO [MssExec]
GRANT DELETE ON [dbo].[ManufacturerAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[ManufacturerAddress] TO [MssExec]
GO