Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the University database below. Notes: - Course.NbrSt: number of students taking that course. - Course.AvgTotal: average of Totals of student-course enrollments from table Enrollment
Consider the University database below. Notes: - Course.NbrSt: number of students taking that course. - Course.AvgTotal: average of Totals of student-course enrollments from table Enrollment for a related course. - Enrollment.Total: summation of 40% of Midterm and 60% of Final. 1) [60 pts] Implement a stored procedure sp_UpdateAvgTotal (Course.CCode) such that - exec sp_UpdateAvgTotal (Course.CCode) updates the field AvgTotal of table Course. The field AvgTotal is the average of Totals of student-course enrollments from table Enrollment for a related course. In order to calculate field AvgTotal of table Course, field Total of table Enrollment is first to be computed by adding 30% of Midterm and 70% of Final. - Create a table for logging errors before creating sp_UpdateAvgTotal. Name the table as Log, table will have three fields: LogID, CCode, ErrCode. The primary key will be LogID. The field LogID will be an identity column, CCode will be corresponding CCode that is to be entered, and ErrCode will be " I for "calling invalid course" (i.e. not available in table Course), "NC" for "no enrolled course" (i.e. not available in table Enrollment). You have to enter appropriate records to the table Log. After these errors, the transaction will be rolled back. Data types for the fields are as follows: LogID int; CCode varchar(8); ErrCode varchar(2). 2) [40 pts] Write a trigger that implements the following: - When a record of student (SID) and course (CCode) is inserted, deleted or updated from the table Enrollment, update the field NbrSt field of table Course. - The field NbrSt is the number of students that is enrolled to the related course. - Hint: you can assume there is only one insertion, deletion or update at a time
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started