CREATE TABLE [dbo].[SysuserAddress]
(
[SysuserAddressID] [int] NOT NULL IDENTITY(1, 1),
[SysuserFID] [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].[SysuserAddress] ADD CONSTRAINT [CK_SysUserAddress_AddressType] CHECK (([dbo].[GetAddressTypeName]([AddressTypeFID])='Main'))
GO
ALTER TABLE [dbo].[SysuserAddress] ADD CONSTRAINT [PK_SysuserAddress] PRIMARY KEY NONCLUSTERED ([SysuserAddressID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SysuserAddress] ADD CONSTRAINT [IX_SysuserAddress_AddressType] UNIQUE NONCLUSTERED ([SysuserFID], [AddressTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SysuserAddress] ADD CONSTRAINT [FK_SysuserAddress_AddressType] FOREIGN KEY ([AddressTypeFID]) REFERENCES [dbo].[AddressType] ([AddressTypeID])
GO
ALTER TABLE [dbo].[SysuserAddress] ADD CONSTRAINT [FK_SysuserAddress_CountryCodeStandard] FOREIGN KEY ([CountryCodeStandardFID]) REFERENCES [dbo].[CountryCodeStandard] ([CountryCodeStandardID])
GO
ALTER TABLE [dbo].[SysuserAddress] ADD CONSTRAINT [FK_SysuserAddress_Sysuser] FOREIGN KEY ([SysuserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[SysuserAddress] TO [MssExec]
GRANT INSERT ON [dbo].[SysuserAddress] TO [MssExec]
GRANT DELETE ON [dbo].[SysuserAddress] TO [MssExec]
GRANT UPDATE ON [dbo].[SysuserAddress] TO [MssExec]
GO