Skip to content

Commit

Permalink
CREATE OR ALTER VIEW Added for Auth View
Browse files Browse the repository at this point in the history
  • Loading branch information
semalaiappan committed Nov 7, 2024
1 parent 97a6a2b commit 5cb9c25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ IF EXISTS (SELECT 1
DROP INDEX UX_EducationOrganizationIdToStudentUSI ON auth.EducationOrganizationIdToStudentUSI;
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSI'))
DROP VIEW auth.EducationOrganizationIdToStudentUSI;
GO

CREATE VIEW auth.EducationOrganizationIdToStudentUSI AS
CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSI AS
SELECT edOrgs.SourceEducationOrganizationId, ssa.StudentUSI, COUNT_BIG(*) AS Ignored
FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs
INNER JOIN edfi.StudentSchoolAssociation ssa
Expand All @@ -29,12 +25,8 @@ IF EXISTS (SELECT 1
DROP INDEX UX_EducationOrganizationIdToParentUSI ON auth.EducationOrganizationIdToParentUSI;
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToParentUSI'))
DROP VIEW auth.EducationOrganizationIdToParentUSI;
GO

CREATE OR ALTER VIEW auth.EducationOrganizationIdToParentUSI AS
SELECT edOrgs.SourceEducationOrganizationId, spa.ParentUSI
SELECT edOrgs.SourceEducationOrganizationId, spa.ParentUSI, COUNT_BIG(*) AS Ignored
FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs
INNER JOIN edfi.StudentSchoolAssociation ssa
ON edOrgs.TargetEducationOrganizationId = ssa.SchoolId
Expand All @@ -43,11 +35,7 @@ CREATE OR ALTER VIEW auth.EducationOrganizationIdToParentUSI AS
GROUP BY edOrgs.SourceEducationOrganizationId, spa.ParentUSI
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStaffUSI'))
DROP VIEW auth.EducationOrganizationIdToStaffUSI;
GO

CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS
CREATE OR ALTER VIEW auth.EducationOrganizationIdToStaffUSI AS

-- EdOrg Assignments
SELECT edOrgs.SourceEducationOrganizationId, seo_assign.StaffUSI
Expand All @@ -64,14 +52,10 @@ CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS
ON edOrgs.TargetEducationOrganizationId = seo_empl.EducationOrganizationId
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSIThroughResponsibility'))
DROP VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility;
GO

CREATE VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS
CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS
SELECT edOrgs.SourceEducationOrganizationId, seora.StudentUSI
FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs
INNER JOIN edfi.StudentEducationOrganizationResponsibilityAssociation seora
ON edOrgs.TargetEducationOrganizationId = seora.EducationOrganizationId
GROUP BY edOrgs.SourceEducationOrganizationId, seora.StudentUSI
GO
GO
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,22 @@ IF EXISTS (SELECT 1
DROP INDEX UX_EducationOrganizationIdToStudentUSI ON auth.EducationOrganizationIdToStudentUSI;
GO


IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSI'))
DROP VIEW auth.EducationOrganizationIdToStudentUSI;
GO


CREATE VIEW auth.EducationOrganizationIdToStudentUSI AS
CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSI AS
SELECT edOrgs.SourceEducationOrganizationId, ssa.StudentUSI, COUNT_BIG(*) AS Ignored
FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs
INNER JOIN edfi.StudentSchoolAssociation ssa
ON edOrgs.TargetEducationOrganizationId = ssa.SchoolId
GROUP BY edOrgs.SourceEducationOrganizationId, ssa.StudentUSI
GO


IF EXISTS (SELECT 1
FROM sys.indexes
WHERE name = 'UX_EducationOrganizationIdToContactUSI'
AND object_id = OBJECT_ID('auth.EducationOrganizationIdToContactUSI'))
DROP INDEX UX_EducationOrganizationIdToContactUSI ON auth.EducationOrganizationIdToContactUSI;
GO


IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToContactUSI'))
DROP VIEW auth.EducationOrganizationIdToContactUSI;
GO

CREATE VIEW auth.EducationOrganizationIdToContactUSI AS
CREATE OR ALTER VIEW auth.EducationOrganizationIdToContactUSI AS
SELECT edOrgs.SourceEducationOrganizationId, spa.ContactUSI, COUNT_BIG(*) AS Ignored
FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs
INNER JOIN edfi.StudentSchoolAssociation ssa
Expand All @@ -47,12 +35,7 @@ CREATE VIEW auth.EducationOrganizationIdToContactUSI AS
GROUP BY edOrgs.SourceEducationOrganizationId, spa.ContactUSI
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStaffUSI'))
DROP VIEW auth.EducationOrganizationIdToStaffUSI;
GO


CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS
CREATE OR ALTER VIEW auth.EducationOrganizationIdToStaffUSI AS

-- EdOrg Assignments
SELECT edOrgs.SourceEducationOrganizationId, seo_assign.StaffUSI
Expand All @@ -69,14 +52,10 @@ CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS
ON edOrgs.TargetEducationOrganizationId = seo_empl.EducationOrganizationId
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSIThroughResponsibility'))
DROP VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility;
GO

CREATE VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS
CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS
SELECT edOrgs.SourceEducationOrganizationId, seora.StudentUSI
FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs
INNER JOIN edfi.StudentEducationOrganizationResponsibilityAssociation seora
ON edOrgs.TargetEducationOrganizationId = seora.EducationOrganizationId
GROUP BY edOrgs.SourceEducationOrganizationId, seora.StudentUSI
GO
GO

0 comments on commit 5cb9c25

Please sign in to comment.