(solution) Running head: STRUCTURED QUERY LANGUAGE FOR DATA MANAGEMENT

(solution) Running head: STRUCTURED QUERY LANGUAGE FOR DATA MANAGEMENT

This assignment requires you to take your extended design from Week 4 IP and add proper indexes, a function, and a stored procedure. Your changes will provide functionality used by the teachers for screens such as a grade book. Be sure any code is properly formatted and has appropriate comments.

Part 1: Function

Write a user-defined function (UDF) that calculates a student’s GPA for a given time frame. Inputs are StudentId int, ClassStartDateStart datetime, and ClassStartDateEnd datetime. The output should be the student’s GPA for all classes that were taken between ClassStartDateStart and ClassStartDateEnd. Also, supply the script to call this new function, passing it parameter values of your choice.

Part 2: Stored Procedure

Write the DDL script to make a stored procedure that returns data needed to display a grade book screen for a professor. The only input for the stored procedure is a ClassId. Outputs need to include student names and grades for all assignments as well as a calculated overall grade for the class for each student. Provide an example calling this new stored procedure, passing it parameter values of your choice. Include a screenshot of the output.

Part 3: Indexes

Provide a list of suggested indexes and the DDL script to create them. Include an explanation of the purpose of indexes and how you made your decision for the fields to include in your list of suggested indexes.

Copy and paste the work into your Key Assignment document and include screen shots of each step, describe what you did for each step and paste in the actual SQL text used to perform each step. Upload your document to the Submitted Tasks.

Please submit your assignment.

Running head: STRUCTURED QUERY LANGUAGE FOR DATA MANAGEMENT Structured Query Language for Data Management
Antonio Larkin
9/10/16 Structured Query Language for Data Management
Creating Tables Degrees and Degrees_Classes, Altering Table Students
CREATE TABLE dbo.[Degrees]
(
DegreeID int NOT NULL IDENTITY(1,1),
DegreeName nvarchar(100)NOT NULL,
[Description] text NULL,
PRIMARY KEY (DegreeID)
)
CREATE TABLE dbo.[Degrees_Classes]
(
DegreeClassID int NOT NULL IDENTITY(1,1),
0 0 STRUCTURED QUERY LANGUAGE FOR DATA MANAGEMENT
1
ClassID int NOT NULL,
DegreeID int NOT NULL,
PRIMARY KEY (DegreeClassID),
FOREIGN KEY (ClassID)
REFERENCES Classes(ClassID),
FOREIGN KEY (DegreeID)
REFERENCES [Degrees](DegreeID)
)
ALTER TABLE Students
ADD DegreeID int NULL
FOREIGN KEY (DegreeID)
REFERENCES [Degrees](DegreeID)
Updated Diagram Inserting Test Records
INSERT INTO dbo.[Degrees] STRUCTURED QUERY LANGUAGE FOR DATA MANAGEMENT
2
(DegreeName, [Description])
VALUES
('Bachelor of Technology', 'The program prepares graduates for career advancement in health
science technology or engineering/applied science technology industries.')
INSERT INTO dbo.[Degrees]
(DegreeName, [Description])
VALUES
('Bachelor of Animal Science', 'Bachelors degree programs in animal science provide students
with a basic understanding of agribusiness, livestock culture, and the preparation of animals for
food production purposes.')
INSERT INTO dbo.[Degrees]
(DegreeName, [Description])
VALUES
('Bachelor of Science in Biomedical Technology', 'B.S. programs in Biomedical Technology
teach students about applied biochemistry, advanced sciences and basic biomedical concepts.') UPDATE dbo.Students
SET DegreeID='1'
WHERE StudentID='1'
UPDATE dbo.Students
SET DegreeID='3' STRUCTURED QUERY LANGUAGE FOR DATA MANAGEMENT
3
WHERE StudentID='2'
UPDATE dbo.Students
SET DegreeID='1'
WHERE StudentID='3'
UPDATE dbo.Students
SET DegreeID='2'
WHERE StudentID='4' INSERT INTO Degrees_Classes (DegreeID, ClassID)
VALUES ('1','3')
INSERT INTO Degrees_Classes (DegreeID, ClassID)
VALUES ('3','4')
INSERT INTO Degrees_Classes (DegreeID, ClassID)
VALUES ('2','1')