----------------------------------------------------------------
--                                                              
--  File:  Create_Check_Constraints_Scaling.SQL                 
--          Microsoft TPC-E Benchmark Kit Ver. 1.14.0-1031      
--          Copyright Microsoft, 2008-2015                  
--                                                              
----------------------------------------------------------------
USE tpce
GO

-- *** CUSTOMER ***
IF NOT EXISTS ( SELECT name FROM sys.check_constraints Where name = 'CK_C_TIER' )
    ALTER TABLE CUSTOMER ADD CONSTRAINT CK_C_TIER
	    CHECK (C_TIER in (1,2,3))
GO
IF NOT EXISTS ( SELECT name FROM sys.check_constraints Where name = 'CK_C_GNDR' )
    ALTER TABLE CUSTOMER ADD CONSTRAINT CK_C_GNDR
	    CHECK (C_GNDR in ('M', 'F'))
GO

-- *** CUSTOMER_ACCOUNT ***
IF NOT EXISTS ( SELECT name FROM sys.check_constraints Where name = 'CK_CA_TAX_ST' )
    ALTER TABLE CUSTOMER_ACCOUNT ADD CONSTRAINT CK_CA_TAX_ST
	    CHECK (CA_TAX_ST in (0,1,2))
GO

-- *** FINANCIAL ***
IF NOT EXISTS ( SELECT name FROM sys.check_constraints Where name = 'CK_FINANCIAL_QTR' )
    ALTER TABLE FINANCIAL ADD CONSTRAINT CK_FINANCIAL_QTR
	    CHECK (FI_QTR in (1,2,3,4))
GO
