Question: Create a file Assignment 6 . sql and add commented queries that do what is needed for the tasks that follow. When creating a table

Create a file Assignment6.sql and add commented queries that do what is needed for the tasks that follow.
When creating a table table_name or view wiew_name, use this syntax to avoid errors when re-running:
DROP TABLE IF EXISTS table_name;
CREATE TABLE table_name...
CREATE OR REPLACE VIEW view_name AS SELECT...
followed by the statement that generates the content of the table or view
[4] Create a table grade_points (grade, points) that maps letter grades to number grades.
The highest grade is A (=4.0), the lowest is F (=0.0), and a + and - respectively increase / decrease the value by 0.3(i.e. B+=3.3 and B-=2.7). There is no grade A+ or F-.
Set grade as your primary key, both because it is inherently appropriate to have a primary key and because you need it (or at least a unique constraint) for the foreign key in the next task.
Create a "check constraint" to ensure that the points attribute is within the range [0,4]. The syntax for a check constraint is CONSTRAINT constraint_name CHECK(constraint conditions...). Beware that some older versions of MySQL parse and store the check constraint, but do not enforce it; go ahead and add it, and dont worry if it isnt enforced.
[5] Add a foreign key from the grade column in the existing takes table to the new grade_points table.
Use the syntax ALTER TABLE table_name followed by the changes to the table
[6] Create a view v_takes_points that returns the data in takes table along with the numeric equivalent of the grade.
[7] Compute the total number of grade points (credits * grade points) earned by student X (pick a student id from the DB). You will need to join takes, course, and the new grade_points tables. If the student is in the system, but hasn't taken any courses, the student's total points is 0.
[8] Compute the GPA - i.e. total grade points / total credits - for the same student in the previous question.
[9] Find the GPA of all students, i.e. not just for one student at a time.
[10] Create a view v_student_gpa (id, gpa) that gives a dynamic version of the information in the previous question.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!