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.FBCSUBClaimOccurrenceCodes
(
--authoritative sources:
--A06.CDWWork.FBCS.UB92
--,<occcode_box31a, varchar(8000),>
-- ,<occdate_box31a, datetime2(7),>
-- ,<occcode_box31b, varchar(8000),>
-- ,<occdate_box31b, datetime2(7),>
-- ,<occcode_box32a, varchar(8000),>
-- ,<occdate_box32a, datetime2(7),>
-- ,<occcode_box32b, varchar(8000),>
-- ,<occdate_box32b, datetime2(7),>
-- ,<occcode_box33a, varchar(8000),>
-- ,<occdate_box33a, datetime2(7),>
-- ,<occcode_box33b, varchar(8000),>
-- ,<occdate_box33b, datetime2(7),>
-- ,<occcode_box34a, varchar(8000),>
-- ,<occdate_box34a, datetime2(7),>
-- ,<occcode_box34b, varchar(8000),>
-- ,<occdate_box34b, datetime2(7),>
-- ,<occspancode_box35a, varchar(8000),>
-- ,<occspanfrom_box35a, datetime2(7),>
-- ,<occspanthrough_box35a, datetime2(7),>
-- ,<occspancode_box35b, varchar(8000),>
-- ,<occspanfrom_box35b, datetime2(7),>
-- ,<occspanthrough_box35b, datetime2(7),>
-- ,<occspancode_box36a, varchar(8000),>
-- ,<occspanfrom_box36a, datetime2(7),>
-- ,<occspanthrough_box36a, datetime2(7),>
-- ,<occspancode_box36b, varchar(8000),>
-- ,<occspanfrom_box36b, datetime2(7),>
-- ,<occspanthrough_box36b, datetime2(7),>

--fields
FBCSUBClaimOccurrenceCodeID bigint IDENTITY(1,1) NOT NULL, --EPRS assigned (PK)
FBCSUBClaimID bigint, --EPRS assigned (FK), references FBCSUBClaims
OccurrenceCodeID smallint NOT NULL, --EPRS assigned (FK), references OccurrenceCodes
BatchLogID bigint, --ERPS assigned (FK), references BatchLogs
OccurenceCodeReference varchar(20) NOT NULL, --identifies box that comes from (31-36, a/b combos)
DateFrom datetime2(7), --date from (use this field for occcodes with only one date)
DateThrough datetime2(7), --date through (this field will only be filled on occ span codes)

--primary key
CONSTRAINT PK_FBCSUBClaimOccurrenceCodes PRIMARY KEY NONCLUSTERED --not clustered due to clust. columnstore index
(
FBCSUBClaimOccurrenceCodeID ASC
)
)
ON CoreData
--when using clustered columnstore index, can't set data compression to PAGE
--WITH (DATA_COMPRESSION = PAGE)
GO

--foreign keys
ALTER TABLE dbo.FBCSUBClaimOccurrenceCodes
ADD CONSTRAINT FK_FBCSUBClaimOccurrenceCodes_FBCSUBClaims
FOREIGN KEY (FBCSUBClaimID)
REFERENCES dbo.FBCSUBClaims (FBCSUBClaimID)
GO

ALTER TABLE dbo.FBCSUBClaimOccurrenceCodes
ADD CONSTRAINT FK_FBCSUBClaimOccurrenceCodes_OccurrenceCodes
FOREIGN KEY (OccurrenceCodeID)
REFERENCES dbo.OccurrenceCodes (OccurrenceCodeID)
GO

ALTER TABLE dbo.FBCSUBClaimOccurrenceCodes
ADD CONSTRAINT FK_FBCSUBClaimOccurrenceCodes_BatchLogs
FOREIGN KEY (BatchLogID)
REFERENCES dbo.BatchLogs (BatchLogID)
GO

--indexes
/**
--Create clustered columnstore index that doesn't exist yet
CREATE CLUSTERED COLUMNSTORE INDEX CCIX_FBCSUBClaimOccurrenceCodes ON dbo.FBCSUBClaimOccurrenceCodes
WITH
(
/*DROP_EXISTING = ON --if the index doesn't exist and this is active,
-- the code will go boom
,*/ MAXDOP = 1 --while 0 uses max degrees of parallelism, 1 in
-- this case helps tighten the ordering when
-- initially using a traditional clustered index
--SQL 2016-- , COMPRESSION_DELAY = 10 --in minutes; increase to 60 if doing OLTP to
--maintain data in deltarowgroup for 60 minutes
, DATA_COMPRESSION = COLUMNSTORE --or COLUMNSTORE_ARCHIVE
)
ON CoreData --keep the clustered columnstore with the data filegroup rather than index filegroup
GO
**/
--TODO: Are the traditional non-clustered indexes still needed?
CREATE NONCLUSTERED INDEX IX_FBCSUBClaimOccurrenceCodes_FBCSUBClaimID ON dbo.FBCSUBClaimOccurrenceCodes
(
FBCSUBClaimID
) 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 = PAGE --use page compression; default = NONE
)
ON CoreIndex
GO

CREATE NONCLUSTERED INDEX IX_FBCSClaimConditionCodes_ConditionCodeID ON dbo.FBCSUBClaimOccurrenceCodes
(
OccurrenceCodeID
) 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 = PAGE --use page compression; default = NONE
)
ON CoreIndex
GO

CREATE NONCLUSTERED INDEX IX_FBCSClaimConditionCodes_OccurenceCodeReference ON dbo.FBCSUBClaimOccurrenceCodes
(
OccurenceCodeReference
) 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 = PAGE --use page compression; default = NONE
)
ON CoreIndex
GO

--constraints

--Metadata descriptions for each field
EXECUTE sp_addextendedproperty
N'MS_Description', N'Primary Key, unique to EPRS; authoritative source table is A06.CDWWork.FBCS.ub92',
N'SCHEMA', N'dbo',
N'TABLE', N'FBCSUBClaimOccurrenceCodes',
N'COLUMN', N'FBCSUBClaimOccurrenceCodeID'
GO

EXECUTE sp_addextendedproperty
N'MS_Description', N'Foreign key, unique to EPRS, relates to the FBCS UB Claims table',
N'SCHEMA', N'dbo',
N'TABLE', N'FBCSUBClaimOccurrenceCodes',
N'COLUMN', N'FBCSUBClaimID'
GO

EXECUTE sp_addextendedproperty
N'MS_Description', N'Foreign key, unique to EPRS, relates to Occurrence Codes table',
N'SCHEMA', N'dbo',
N'TABLE', N'FBCSUBClaimOccurrenceCodes',
N'COLUMN', N'OccurrenceCodeID'
GO

EXECUTE sp_addextendedproperty
N'MS_Description', N'Foreign key, unique to EPRS, relates to Batch Logs table',
N'SCHEMA', N'dbo',
N'TABLE', N'FBCSUBClaimOccurrenceCodes',
N'COLUMN', N'BatchLogID'
GO

EXECUTE sp_addextendedproperty
N'MS_Description', N'Reference for the occurrence /span code, which box it comes from (e.g., 31a, 31b, 32a, 32b, etc.)',
N'SCHEMA', N'dbo',
N'TABLE', N'FBCSUBClaimOccurrenceCodes',
N'COLUMN', N'OccurenceCodeReference'
GO