Question: Part 2 : Database Creation and SQL Queries ( 9 0 marks ) In this part of the assignment, you will create a database and
Part : Database Creation and SQL Queries marks
In this part of the assignment, you will create a database and perform a series of tasks to test your understanding of SQL Each task has specific marks assigned to it
Task : Create a Database and Tables marks
Create a new database named university. marks
Create the following tables based on the schema:
o Student table:
ID Primary Key
name
deptname
totcred
o Course table:
courseid Primary Key
title
deptname
credits
marks for each table
Task : Insert Data into Tables marks
Insert rows of data into the student table. marks Example:
ID name, deptname, totcred
'Alice', 'Comp. Sci.
'Bob', 'Physics',
'Carol', 'Mathematics',
'Dave', 'Biology',
'Eve', 'Chemistry', ;
Insert rows of data into the course table. marks Example:
courseid title, deptname, credits
CS 'Intro to Computer Science', 'Comp. Sci.
PH 'Intro to Physics', 'Physics',
MA 'Calculus I 'Mathematics',
BI 'Biology Basics', 'Biology',
CH 'Introduction to Chemistry', 'Chemistry', ;
Task : Simple Queries marks
Perform the following SQL queries and include the output:
List all students from the student table. marks
Find all courses in the 'Comp. Sci. department. marks
Find the total number of credits for a student whose ID is marks
Find all students who have earned more than total credits. marks
List the course titles and department names of all courses. marks
Count the number of students in the 'Physics' department. marks
Task : Update and Delete Data marks
Update the total credits for the student with ID to marks
Increase the credits of all courses in the 'Comp. Sci. department by marks
Delete all courses in the 'Biology' department. marks
Delete a student from the student table whose ID is marks
Bonus Task: Nested Queries marks
For this bonus task, you will need to write nested queries to answer more complex questions.
Each query should demonstrate your understanding of how to use subqueries effectively in SQL
Bonus Task : Find Students Who Have Taken All Courses in a Specific Department marks
Write a query to find all students who have taken all the courses offered by the 'Comp. Sci. department.
Hint: Use a nested query to first select all the courses from the 'Comp. Sci. department, and then compare it with the courses that each student has taken.
Bonus Task : Find Courses with Enrollment Greater Than the Average Enrollment
marks
Write a query to find all courses that have an enrollment greater than the average enrollment of
all courses.
Hint: Use a nested query to compute the average enrollment first, and then compare it with the enrollment of each course.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
