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.CCRAHospitals
(
--authoritative source:
--A06.CDWWork.CCRA.ct_hospital
--fields
HospitalRowNumber bigint NOT NULL, --EPRS assigned (PK) ,hosp_rowid
StationID smallint NULL, --allow NULLS since Hospital Code has Station + other values
CityRowNumber bigint NOT NULL,
RegionRowNumber bigint NOT NULL,
HospitalCode VARCHAR(100),
HospitalName VARCHAR(100),
--primary key
CONSTRAINT PK_CCRAHospitals PRIMARY KEY NONCLUSTERED --not clustered due to clust. columnstore index
(
HospitalRowNumber ASC
)
)
ON CoreData ---could also be definition data?
--when using clustered columnstore index, can't set data compression to PAGE
--WITH (DATA_COMPRESSION = PAGE)
GO
--foreign keys
ALTER TABLE dbo.CCRAHospitals
ADD CONSTRAINT FK_CCRAHospitals_StationID
FOREIGN KEY (StationID)
REFERENCES dbo.Stations (StationID)
GO
ALTER TABLE dbo.CCRAHospitals
ADD CONSTRAINT FK_CCRAHospitals_CityRowNumber
FOREIGN KEY (CityRowNumber)
REFERENCES dbo.CCRACities (CityRowNumber)
GO
ALTER TABLE dbo.CCRAHospitals
ADD CONSTRAINT FK_CCRAHospitals_RegionRowNumber
FOREIGN KEY (RegionRowNumber)
REFERENCES dbo.CCRARegions (RegionRowNumber)
GO
--indexes
--TODO: Are the traditional non-clustered indexes still needed?
CREATE NONCLUSTERED INDEX IX_CCRAHospitals_StationID ON dbo.CCRAHospitals
(
StationID
) 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_CCRAHospitals_CityRowNumber ON dbo.CCRAHospitals
(
CityRowNumber
) 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_CCRAHospitals_RegionRowNumber ON dbo.CCRAHospitals
(
RegionRowNumber
) 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, hosp_rowid in source',
N'SCHEMA', N'dbo',
N'TABLE', N'CCRAHospitals',
N'COLUMN', N'HospitalRowNumber'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'FK to Stations',
N'SCHEMA', N'dbo',
N'TABLE', N'CCRAHospitals',
N'COLUMN', N'StationID'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'FK to CCRACities',
N'SCHEMA', N'dbo',
N'TABLE', N'CCRAHospitals',
N'COLUMN', N'CityRowNumber'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'FK to CCRARegions',
N'SCHEMA', N'dbo',
N'TABLE', N'CCRAHospitals',
N'COLUMN', N'RegionRowNumber'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'VA Facility Station Number or Community Provider NPI',
N'SCHEMA', N'dbo',
N'TABLE', N'CCRAHospitals',
N'COLUMN', N'HospitalCode'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'VA Facility or Community Provider/Facility Name',
N'SCHEMA', N'dbo',
N'TABLE', N'CCRAHospitals',
N'COLUMN', N'HospitalName'
GO