text: ﻿Create Table [Hrm].[EmployeesAddresses]
  (
  	[AddressId] Uniqueidentifier Not Null Default NEWID(),
  	[AddressType] Int Not Null,
  	[AddressTypeName] As 
  		Case [AddressType]
  			When 1 Then 'Mailing Address'
  			When 2 Then 'Primary Address'
  		End,
  	[EmployeeId] Uniqueidentifier Not Null,
  	[StreetOne] Varchar(1000) Not Null,
  	[StreetTwo] Varchar(1000) Null,
  	[StreetThree] Varchar(1000) Null,
  	[StateOrRegion] Varchar(255) Not Null,
  	[Province] Varchar(255) Null,
  	[County] Varchar Null,
  	[PostalCode] Varchar(10) Null,
  	[AreaCode] Varchar(25) Null,
  	[Country] Varchar(255) Not Null,
  	[CountryCode] Varchar(5) Null,
  	[DateCreated] Date Not Null Default GETDATE(),
  	[DateUpdated] Date Not Null Default GETDATE(),
  	[CreatedBy] Varchar(255),
  	[UpdatedBy] Varchar(255)
  
  	Constraint PrimaryKeyAddressId Primary Key Clustered([AddressId]),
  	Constraint ForeignKeyEmployeeIdToAddress Foreign Key([EmployeeId]) References [Hrm].[Employees]([EmployeeId])
  		On Delete Cascade,
  	Constraint CheckAddressType Check([AddressType] = 1 Or [AddressType] = 2)
  )
  Go
  
  Create Trigger [Hrm].[EmployeesAddressPostUpdate]
  On [Hrm].[EmployeesAddresses]
  After Update
  As 
  	Update [Hrm].[EmployeesAddresses]
  	Set [DateUpdated] = GETDATE()
  	From [Hrm].[EmployeesAddresses] Inner Join inserted
  	On [Hrm].[EmployeesAddresses].[AddressId] = inserted.AddressId