Question
WRITE IN MYSQL 1.a) Create a view called student_registrations which will contain the first name and last name of the student, the name and number
WRITE IN MYSQL
1.a) Create a view called student_registrations which will contain the first name and last name of the student, the name and number of credits of the courses where they are registered, the start date and end date of courses and the grade. The view will have the following header:
first_name- last_name- course- credits-stard date-end date-grade
Use the view to display only the students who have finished their courses, ordered by the course name in ascending order and by the grade in descending order.
1.b) Create a trigger for the INSERT operation on the registrations table to check that theend date of the course is after the start date. If not, an error will be raised. Choose the appropriate activation time for the trigger and explain how it works
1.c) Create a procedure to register a student to a course. The procedure will check if the course hasnt already started or ended, according to the specified parameters and todays date, otherwise an error will be raised. Explain how the procedure works
Consider the following EER diagram: courses HPK lid INT UNSIGNED students PK lid INT UNSIGNED first name VARCHAR(255) last_name VARCHAR(255) email VARCHAR(255) name registrations PK, FK student_id INT UNSIGNED PK, FK course_id INT UNSIGNED start_date DATE end_date DATE grade DECIMAL(10,2) VARCHAR(255) TINYINT UNSIGNED credits content TEXT with the following sample data: students id first_name last_name 1 lon Pop 2 Laura Dumitru 3 Alin lonescu email ion.pop@gmail.com laura.dumitru@gmail.com alin.ionescu@gmail.com courses id name 1 Databases 2 Medical Electronics 3 Microcontrollers credits 4 3 content NULL NULL NULL 4 registrations student_id 1 1 2 course id 2 3 1 start date 2020-10-01 2021-01-11 2020-09-15 end date date 2020-12-10 2021-03-01 2020-11-14 grade 8.50 NULL 10.00 1.a) Create a view called student_registrations which will contain the first name and last name of the student, the name and number of credits of the courses where they are registered, the start date and end date of courses and the grade. The view will have the following header: first name- last name Course credits stare end date grade Use the view to display only the students who have finished their courses, ordered by the course name in ascending order and by the grade in descending order. 1.b) Create a trigger for the INSERT operation on the registrations table to check that the end date of the course is after the start date. If not, an error will be raised. Choose the appropriate activation time for the trigger and explain how it works 1.c) Create a procedure to register a student to a course. The procedure will check if the course hasn't already started or ended, according to the specified parameters and today's date, otherwise an error will be raised. Explain how the procedure worksStep 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