Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
?CREATE TABLE dbo.Reasons
(
--authoritative source:
--A06.CDWWork.FBCS.reasons
--A06.CDWWork.FBCS.suspensionreasons (tagged with ReasonTypeID associated with reason name = Suspended)
--fields
ReasonID smallint IDENTITY(1,1) NOT NULL, --EPRS assigned (PK)
ReasonTypeID tinyint, --EPRS assigned (FK), reference ReasonTypes, reason
ReasonName varchar (1000), --reason
Verbage varchar (1000), --verbage
ProgramNumber int, --program
IsEnabled bit, --enabled
--primary key
CONSTRAINT PK_Reasons PRIMARY KEY CLUSTERED
(
ReasonID ASC
)
)
ON DefinitionData
--when using clustered columnstore index, can't set data compression to PAGE
--WITH (DATA_COMPRESSION = PAGE) --less than 10,000 rows, don't need compression
GO
--foreign keys
ALTER TABLE dbo.Reasons
ADD CONSTRAINT FK_Reasons_ReasonTypes
FOREIGN KEY (ReasonTypeID)
REFERENCES dbo.ReasonTypes (ReasonTypeID)
GO
--indexes
CREATE NONCLUSTERED INDEX IX_Reasons_ReasonTypeID ON dbo.Reasons
(
ReasonTypeID
) WITH (
PAD_INDEX = ON, --If want to use a Fill Factor, then PAD_INDEX must = ON
FILLFACTOR = 100, --100 = max fill; set to 90 if going to insert new values incrementally; 100 if doing bulk load
SORT_IN_TEMPDB = ON, -- sorts the index in the TempDB; default = OFF
IGNORE_DUP_KEY = OFF,
STATISTICS_NORECOMPUTE = OFF,
STATISTICS_INCREMENTAL = OFF,
DROP_EXISTING = OFF,
ONLINE = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON,
MAXDOP = 0, --degrees of parallelism, controls how many CPUs to use; 0 = default (all available), max = 64
DATA_COMPRESSION = NONE --don't need, less than 10,000 rows
)
ON CoreIndex
GO
--constraints
--Need tri-state? TODO: confirm need tri-state bit
--ALTER TABLE dbo.Reasons
-- ADD CONSTRAINT DF_Reasons_IsEnabled
-- DEFAULT 0
-- FOR IsEnabled
--GO
--Metadata descriptions for each field
EXECUTE sp_addextendedproperty
N'MS_Description', N'Primary Key, unique to EPRS',
N'SCHEMA', N'dbo',
N'TABLE', N'Reasons',
N'COLUMN', N'ReasoniD'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Foreign key, unique to EPRS, relates to Reason Types table, source: reasontype',
N'SCHEMA', N'dbo',
N'TABLE', N'Reasons',
N'COLUMN', N'ReasonTypeID'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Reason name, source: reason',
N'SCHEMA', N'dbo',
N'TABLE', N'Reasons',
N'COLUMN', N'ReasonName'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Reason Description, source: verbage',
N'SCHEMA', N'dbo',
N'TABLE', N'Reasons',
N'COLUMN', N'Verbage'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Program number, values=-1, 1, 2, 3, 4, source: reason',
N'SCHEMA', N'dbo',
N'TABLE', N'Reasons',
N'COLUMN', N'ProgramNumber'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'True/false, identifies if record is enabled (1=yes/true, 0=no/false), source: enabled',
N'SCHEMA', N'dbo',
N'TABLE', N'Reasons',
N'COLUMN', N'IsEnabled'
GO