-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BIA-1310] Update AMT views datatypes and columns (#232)
Update datatypes for views studentAssessmentFact classPeriodDim localEducationAgencyDim schoolDim sectionDim staffSectionDim studentLocalEducationAgencyDim studentProgramDim feederSchoolDim studentDisciplineActionDim rlsStudentDataAuthorization rlsUserAuthorization
- Loading branch information
1 parent
e13732f
commit d060f9b
Showing
268 changed files
with
7,072 additions
and
301 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/EdFi.AnalyticsMiddleTier.DataStandard2/Base/MSSQL/0043-View-ClassPeriodDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'analytics' AND TABLE_NAME = 'ClassPeriodDim') | ||
BEGIN | ||
DROP VIEW analytics.ClassPeriodDim | ||
END | ||
GO | ||
|
||
CREATE VIEW analytics.ClassPeriodDim AS | ||
SELECT | ||
CONCAT(Section.ClassPeriodName, '-', Section.LocalCourseCode, '-', Section.SchoolId, '-', Section.SchoolYear, '-', Section.TermDescriptorId, '-', Section.UniqueSectionCode, '-', Session.SessionName) ClassPeriodKey, | ||
CONCAT(section.SchoolId, '-', Section.ClassPeriodName, '-', section.ClassroomIdentificationCode, '-', Section.LocalCourseCode, '-', Section.TermDescriptorId, '-', Section.SchoolYear, '-', Section.UniqueSectionCode, '-', Section.SequenceOfCourse) as SectionKey, | ||
Section.ClassPeriodName, | ||
Section.LocalCourseCode, | ||
cast(Section.SchoolId as varchar) as SchoolId, | ||
cast(Section.SchoolId as varchar) as SchoolKey, | ||
cast(Section.SchoolYear as varchar) as SchoolYear, | ||
Section.UniqueSectionCode as SectionIdentifier, | ||
Session.SessionName | ||
FROM | ||
edfi.Section | ||
INNER JOIN | ||
edfi.Session ON | ||
Section.SchoolId = Session.SchoolId | ||
AND | ||
Section.SchoolYear = Session.SchoolYear | ||
AND | ||
Section.TermDescriptorId = Session.TermDescriptorId | ||
GO |
49 changes: 49 additions & 0 deletions
49
....AnalyticsMiddleTier.DataStandard2/Base/MSSQL/0044-View-LocalEducationAgencyDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'analytics' AND TABLE_NAME = 'LocalEducationAgencyDim') | ||
BEGIN | ||
DROP VIEW analytics.LocalEducationAgencyDim | ||
END | ||
GO | ||
|
||
CREATE VIEW analytics.LocalEducationAgencyDim AS | ||
|
||
SELECT | ||
CAST(EducationOrganization.EducationOrganizationId AS VARCHAR) as LocalEducationAgencyKey, | ||
EducationOrganization.NameOfInstitution as LocalEducationAgencyName, | ||
ISNULL(LocalEducationAgencyCategoryType.CodeValue, '') as LocalEducationAgencyType, | ||
COALESCE(CAST(LocalEducationAgency.ParentLocalEducationAgencyId AS VARCHAR), '') as LocalEducationAgencyParentLocalEducationAgencyKey, | ||
ISNULL(StateEducationAgency.NameOfInstitution, '') as LocalEducationAgencyStateEducationAgencyName, | ||
COALESCE(CAST(LocalEducationAgency.StateEducationAgencyId AS VARCHAR), '') as LocalEducationAgencyStateEducationAgencyKey, | ||
ISNULL(EducationServiceCenter.NameOfInstitution, '') as LocalEducationAgencyServiceCenterName, | ||
COALESCE(CAST(EducationServiceCenter.EducationOrganizationId AS VARCHAR), '') as LocalEducationAgencyServiceCenterKey, | ||
ISNULL(CharterStatusType.CodeValue, '') as LocalEducationAgencyCharterStatus, | ||
( | ||
SELECT | ||
MAX(MaxLastModifiedDate) | ||
FROM (VALUES (EducationOrganization.LastModifiedDate) | ||
,(EducationServiceCenter.LastModifiedDate) | ||
,(StateEducationAgency.LastModifiedDate) | ||
) AS VALUE (MaxLastModifiedDate) | ||
) AS LastModifiedDate | ||
FROM | ||
edfi.EducationOrganization | ||
INNER JOIN | ||
edfi.LocalEducationAgency ON | ||
EducationOrganization.EducationOrganizationId = LocalEducationAgency.LocalEducationAgencyId | ||
LEFT OUTER JOIN | ||
edfi.LocalEducationAgencyCategoryType ON | ||
LocalEducationAgency.LocalEducationAgencyCategoryTypeId = LocalEducationAgencyCategoryType.LocalEducationAgencyCategoryTypeId | ||
LEFT OUTER JOIN | ||
edfi.EducationOrganization as EducationServiceCenter ON | ||
LocalEducationAgency.EducationServiceCenterId = EducationServiceCenter.EducationOrganizationId | ||
LEFT OUTER JOIN | ||
edfi.CharterStatusType ON | ||
LocalEducationAgency.CharterStatusTypeId = CharterStatusType.CharterStatusTypeId | ||
LEFT OUTER JOIN | ||
edfi.EducationOrganization as StateEducationAgency ON | ||
LocalEducationAgency.StateEducationAgencyId = StateEducationAgency.EducationOrganizationId | ||
GO |
75 changes: 75 additions & 0 deletions
75
src/EdFi.AnalyticsMiddleTier.DataStandard2/Base/MSSQL/0045-View-SchoolDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'analytics' AND TABLE_NAME = 'SchoolDim') | ||
BEGIN | ||
DROP VIEW analytics.SchoolDim | ||
END | ||
GO | ||
|
||
CREATE VIEW analytics.SchoolDim | ||
AS | ||
SELECT CAST(School.SchoolId AS VARCHAR) AS SchoolKey, | ||
EducationOrganization.NameOfInstitution AS SchoolName, | ||
COALESCE(SchoolType.CodeValue, '') AS SchoolType, | ||
COALESCE(SchoolAddress.SchoolAddress, '') AS SchoolAddress, | ||
COALESCE(SchoolAddress.SchoolCity, '') AS SchoolCity, | ||
COALESCE(SchoolAddress.SchoolCounty, '') AS SchoolCounty, | ||
COALESCE(SchoolAddress.SchoolState, '') AS SchoolState, | ||
COALESCE(EdOrgLocal.NameOfInstitution, '') AS LocalEducationAgencyName, | ||
COALESCE(CAST(EdOrgLocal.EducationOrganizationId AS VARCHAR), '') AS LocalEducationAgencyKey, | ||
COALESCE(EdOrgState.NameOfInstitution, '') AS StateEducationAgencyName, | ||
COALESCE(CAST(EdOrgState.EducationOrganizationId AS VARCHAR), '') AS StateEducationAgencyKey, | ||
COALESCE(EdOrgServiceCenter.NameOfInstitution, '') AS EducationServiceCenterName, | ||
COALESCE(CAST(EdOrgServiceCenter.EducationOrganizationId AS VARCHAR), '') AS EducationServiceCenterKey, | ||
( | ||
SELECT MAX(MaxLastModifiedDate) | ||
FROM(VALUES(EducationOrganization.LastModifiedDate), (SchoolType.LastModifiedDate), (EdOrgLocal.LastModifiedDate), (EdOrgState.LastModifiedDate), (EdOrgServiceCenter.LastModifiedDate), (SchoolAddress.LastModifiedDate)) AS VALUE(MaxLastModifiedDate) | ||
) AS LastModifiedDate | ||
FROM edfi.School | ||
INNER JOIN | ||
edfi.EducationOrganization | ||
ON School.SchoolId = EducationOrganization.EducationOrganizationId | ||
LEFT OUTER JOIN | ||
edfi.SchoolType | ||
ON School.SchoolTypeId = SchoolType.SchoolTypeId | ||
LEFT OUTER JOIN | ||
edfi.LocalEducationAgency | ||
ON School.LocalEducationAgencyId = LocalEducationAgency.LocalEducationAgencyId | ||
LEFT OUTER JOIN | ||
edfi.EducationOrganization AS EdOrgLocal | ||
ON School.LocalEducationAgencyId = EdOrgLocal.EducationOrganizationId | ||
LEFT OUTER JOIN | ||
edfi.EducationOrganization AS EdOrgState | ||
ON LocalEducationAgency.StateEducationAgencyId = EdOrgState.EducationOrganizationId | ||
LEFT OUTER JOIN | ||
edfi.EducationOrganization AS EdOrgServiceCenter | ||
ON LocalEducationAgency.EducationServiceCenterId = EdOrgServiceCenter.EducationOrganizationId | ||
OUTER APPLY | ||
( | ||
SELECT TOP 1 CONCAT(EducationOrganizationAddress.StreetNumberName, ', ', (EducationOrganizationAddress.ApartmentRoomSuiteNumber + ', '), EducationOrganizationAddress.City, ' ', StateAbbreviationType.CodeValue, ' ', EducationOrganizationAddress.PostalCode) AS SchoolAddress, | ||
EducationOrganizationAddress.City AS SchoolCity, | ||
EducationOrganizationAddress.NameOfCounty AS SchoolCounty, | ||
StateAbbreviationType.CodeValue AS SchoolState, | ||
EducationOrganizationAddress.BeginDate AS LastModifiedDate | ||
FROM edfi.EducationOrganizationAddress | ||
INNER JOIN | ||
edfi.AddressType | ||
ON EducationOrganizationAddress.AddressTypeId = AddressType.AddressTypeId | ||
INNER JOIN | ||
edfi.StateAbbreviationType | ||
ON EducationOrganizationAddress.StateAbbreviationTypeId = StateAbbreviationType.StateAbbreviationTypeId | ||
INNER JOIN | ||
analytics_config.TypeMap | ||
ON AddressType.AddressTypeId = TypeMap.TypeId | ||
INNER JOIN | ||
analytics_config.DescriptorConstant | ||
ON DescriptorConstant.DescriptorConstantId = TypeMap.DescriptorConstantId | ||
WHERE School.SchoolId = EducationOrganizationAddress.EducationOrganizationId | ||
AND EducationOrganizationAddress.EndDate IS NULL | ||
AND DescriptorConstant.ConstantName = 'Address.Physical' | ||
) AS SchoolAddress; | ||
GO | ||
|
94 changes: 94 additions & 0 deletions
94
src/EdFi.AnalyticsMiddleTier.DataStandard2/Base/MSSQL/0046-View-SectionDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
IF EXISTS ( | ||
SELECT 1 | ||
FROM INFORMATION_SCHEMA.VIEWS | ||
WHERE TABLE_SCHEMA = 'analytics' | ||
AND TABLE_NAME = 'SectionDim' | ||
) | ||
BEGIN | ||
DROP VIEW analytics.SectionDim | ||
END | ||
GO | ||
|
||
CREATE VIEW [analytics].[SectionDim] | ||
AS | ||
SELECT CAST(s.SchoolId AS VARCHAR) AS SchoolKey | ||
,CONCAT ( | ||
CAST(s.SchoolId AS NVARCHAR) | ||
,'-' | ||
,[s].[ClassPeriodName] | ||
,'-' | ||
,[s].[ClassroomIdentificationCode] | ||
,'-' | ||
,s.[LocalCourseCode] | ||
,'-' | ||
,CAST([s].[TermDescriptorId] AS NVARCHAR) | ||
,'-' | ||
,CAST(s.[SchoolYear] AS NVARCHAR) | ||
,'-' | ||
,s.[UniqueSectionCode] | ||
,'-' | ||
,CAST(s.[SequenceOfCourse] AS NVARCHAR) | ||
) AS [SectionKey] | ||
,CONCAT ( | ||
[Descriptor].[Description] | ||
,'-(' | ||
,s.[LocalCourseCode] | ||
,')' | ||
,'-' | ||
,[Course].[CourseTitle] | ||
,'-(' | ||
,s.[ClassPeriodName] | ||
,')-' | ||
,TermType.Description | ||
) AS Description | ||
,CONCAT ( | ||
[s].[LocalCourseCode] | ||
,'-' | ||
,COALESCE([Course].[CourseTitle], '') | ||
) AS [SectionName] | ||
,Session.SessionName | ||
,[CourseOffering].[LocalCourseCode] | ||
,CAST(s.SchoolYear AS VARCHAR) as SchoolYear | ||
,EducationalEnvironmentType.Description AS EducationalEnvironmentDescriptor | ||
,COALESCE(CAST(sch.LocalEducationAgencyId AS VARCHAR),'') AS LocalEducationAgencyKey | ||
,s.LastModifiedDate | ||
,course.CourseTitle | ||
,CONCAT ( | ||
s.SchoolId | ||
,'-' | ||
,s.SchoolYear | ||
,'-' | ||
,s.TermDescriptorId | ||
) AS SessionKey | ||
FROM [edfi].[Section] s | ||
INNER JOIN [edfi].[CourseOffering] | ||
ON [CourseOffering].[SchoolId] = s.[SchoolId] | ||
AND [CourseOffering].[LocalCourseCode] = s.[LocalCourseCode] | ||
AND CourseOffering.TermDescriptorId = s.TermDescriptorId | ||
AND CourseOffering.SchoolYear = s.SchoolYear | ||
INNER JOIN [edfi].[Course] | ||
ON [Course].[CourseCode] = [CourseOffering].[CourseCode] | ||
AND [Course].[EducationOrganizationId] = [CourseOffering].[EducationOrganizationId] | ||
INNER JOIN edfi.Session | ||
ON Session.SchoolId = s.SchoolId | ||
AND Session.SchoolYear = s.SchoolYear | ||
AND Session.TermDescriptorId = s.TermDescriptorId | ||
LEFT JOIN [edfi].[School] sch | ||
ON sch.SchoolId = [Course].[EducationOrganizationId] | ||
LEFT OUTER JOIN [edfi].[AcademicSubjectDescriptor] | ||
ON [AcademicSubjectDescriptor].[AcademicSubjectDescriptorId] = [Course].[AcademicSubjectDescriptorId] | ||
LEFT OUTER JOIN [edfi].[Descriptor] | ||
ON [AcademicSubjectDescriptor].[AcademicSubjectDescriptorId] = [Descriptor].[DescriptorId] | ||
LEFT OUTER JOIN [edfi].TermDescriptor | ||
ON TermDescriptor.TermDescriptorId = s.TermDescriptorId | ||
LEFT OUTER JOIN [edfi].TermType | ||
ON TermDescriptor.TermTypeId = TermType.TermTypeId | ||
LEFT OUTER JOIN [edfi].EducationalEnvironmentType | ||
ON EducationalEnvironmentType.EducationalEnvironmentTypeId = s.EducationalEnvironmentTypeId | ||
GO | ||
|
||
|
109 changes: 109 additions & 0 deletions
109
src/EdFi.AnalyticsMiddleTier.DataStandard2/Base/MSSQL/0047-View-StaffSectionDim-Alter.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- Licensed to the Ed-Fi Alliance under one or more agreements. | ||
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
-- See the LICENSE and NOTICES files in the project root for more information. | ||
IF EXISTS ( | ||
SELECT 1 | ||
FROM INFORMATION_SCHEMA.VIEWS | ||
WHERE TABLE_SCHEMA = 'analytics' | ||
AND TABLE_NAME = 'StaffSectionDim' | ||
) | ||
BEGIN | ||
DROP VIEW analytics.StaffSectionDim | ||
END | ||
GO | ||
|
||
CREATE VIEW analytics.StaffSectionDim | ||
AS | ||
SELECT CONCAT ( | ||
s.StaffUniqueId | ||
,'-' | ||
,CAST(StaffSectionAssociation.SchoolId AS NVARCHAR) | ||
,'-' | ||
,StaffSectionAssociation.ClassPeriodName | ||
,'-' | ||
,StaffSectionAssociation.ClassroomIdentificationCode | ||
,'-' | ||
,StaffSectionAssociation.LocalCourseCode | ||
,'-' | ||
,CAST(StaffSectionAssociation.TermDescriptorId AS NVARCHAR) | ||
,'-' | ||
,CAST(StaffSectionAssociation.SchoolYear AS NVARCHAR) | ||
,'-' | ||
,StaffSectionAssociation.UniqueSectionCode | ||
,'-' | ||
,CAST(StaffSectionAssociation.SequenceOfCourse AS NVARCHAR) | ||
) AS StaffSectionKey | ||
,s.StaffUniqueId UserKey | ||
,CAST(StaffSectionAssociation.SchoolId AS VARCHAR) AS SchoolKey | ||
,CONCAT ( | ||
CAST(StaffSectionAssociation.SchoolId AS NVARCHAR) | ||
,'-' | ||
,StaffSectionAssociation.ClassPeriodName | ||
,'-' | ||
,StaffSectionAssociation.ClassroomIdentificationCode | ||
,'-' | ||
,StaffSectionAssociation.LocalCourseCode | ||
,'-' | ||
,CAST(StaffSectionAssociation.TermDescriptorId AS NVARCHAR) | ||
,'-' | ||
,CAST(StaffSectionAssociation.SchoolYear AS NVARCHAR) | ||
,'-' | ||
,StaffSectionAssociation.UniqueSectionCode | ||
,'-' | ||
,CAST(StaffSectionAssociation.SequenceOfCourse AS NVARCHAR) | ||
) AS SectionKey | ||
,COALESCE(s.PersonalTitlePrefix, '') AS PersonalTitlePrefix | ||
,s.FirstName as StaffFirstName | ||
,COALESCE(s.MiddleName, '') AS StaffMiddleName | ||
,s.LastSurname AS StaffLastName | ||
,COALESCE(sem.ElectronicMailAddress, '') AS ElectronicMailAddress | ||
,COALESCE(st.ShortDescription, '') AS Sex | ||
,COALESCE(cast(s.BirthDate AS VARCHAR(100)), '') AS BirthDate | ||
,( | ||
CASE | ||
WHEN RT.ShortDescription IS NULL | ||
THEN ( | ||
CASE | ||
WHEN RaceDisp.Race IS NULL | ||
THEN 'Unknown' | ||
ELSE 'Multiracial' | ||
END | ||
) | ||
ELSE RT.ShortDescription | ||
END | ||
) AS Race | ||
,CAST(COALESCE(s.HispanicLatinoEthnicity, 0) AS BIT) AS HispanicLatinoEthnicity | ||
,COALESCE(d.ShortDescription, '') AS HighestCompletedLevelOfEducation | ||
,COALESCE(s.YearsOfPriorProfessionalExperience, '0') AS YearsOfPriorProfessionalExperience | ||
,COALESCE(s.YearsOfPriorTeachingExperience, '0') AS YearsOfPriorTeachingExperience | ||
,CAST(COALESCE(s.HighlyQualifiedTeacher, 0) AS BIT) AS HighlyQualifiedTeacher | ||
,COALESCE(s.LoginId, '') AS LoginId | ||
,( | ||
SELECT MAX(MaxLastModifiedDate) | ||
FROM ( | ||
VALUES (s.LastModifiedDate) | ||
,(StaffSectionAssociation.LastModifiedDate) | ||
) AS VALUE(MaxLastModifiedDate) | ||
) AS LastModifiedDate | ||
FROM edfi.Staff s | ||
INNER JOIN edfi.StaffSectionAssociation ON StaffSectionAssociation.StaffUSI = s.StaffUSI | ||
LEFT JOIN edfi.StaffElectronicMail AS sem ON s.StaffUSI = sem.StaffUSI | ||
LEFT JOIN edfi.SexType AS st ON s.SexTypeId = st.SexTypeId | ||
LEFT JOIN ( | ||
SELECT DISTINCT t1.StaffUSI | ||
,STUFF(( | ||
SELECT CAST(t2.RaceTypeId AS VARCHAR(100)) | ||
FROM edfi.StaffRace t2 | ||
WHERE t2.StaffUSI = t1.StaffUSI | ||
FOR XML PATH('') | ||
), 1, 0, '') AS Race | ||
FROM edfi.StaffRace t1 | ||
) AS RaceDisp ON S.StaffUSI = RaceDisp.StaffUSI | ||
LEFT JOIN edfi.RaceType AS RT ON RaceDisp.Race = RT.RaceTypeId | ||
LEFT JOIN edfi.Descriptor AS d ON s.HighestCompletedLevelOfEducationDescriptorId = d.DescriptorId | ||
WHERE StaffSectionAssociation.EndDate IS NULL | ||
OR StaffSectionAssociation.EndDate > GETDATE(); | ||
GO | ||
|
||
|
Oops, something went wrong.