Question
Query 3 (2 pts) For each student, find the number of courses where she or he got an A grade. Output a table consisting of
Query 3 (2 pts)
For each student, find the number of courses where she or he got an A grade. Output a table consisting of two columns: name of student, number of A grades. Write this query without using join or product.
Query 4 (2 pts)
For each course, find the number of students who took this course. Output a table consisting of two columns: title, number of students. Write this query without using join or product.
Query 6 (2 pts)
Find all instructors who teach the maximum number of sections. For each such instructor, output the name and the number of sections.
The pictures attached is the database for these queries
name sql CREATE TABLE classroom (building varchar(15), room_number varchar(7), capacity numeric(4,0), primary key (building, room_number) classroom CREATE TABLE department (dept_name varchar(20), building varchar(15), department budget numeric(12,2) check (budget > 0), primary key (dept_name) CREATE TABLE course (course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) check (credits > 0), primary key (course_id), foreign key (dept_name) references department on delete set null course (ID CREATE TABLE instructor varchar(5), name varchar(20) not null, dept_name varchar(20), instructor salary numeric(8,2) check (salary > 29000), primary key (ID), foreign key (dept_name) references department on delete set null CREATE TABLE section (course_id varchar(8), sec_id varchar(8), semester varchar(6) check (semester in ('Fall', 'Winter', 'Spring', 'Summer')), year numeric(4,0) check (year > 1701 and year 2100), building varchar(15), room_number varchar(7), time_slot_id varchar(4), primary key (course_id, sec_id, semester, year), foreign key (course_1d) references course on delete cascade, foreign key (building, room_number) references classroom on delete set null section CREATE TABLE teaches (ID varchar(5) course_id varchar(8) sec_id varchar(8), semester varchar(6), year numeric (4,0), primary key (ID, course_id, sec_id, semester, year), foreign key (course_id, sec_id, semester, year) references section on delete cascade, foreign key (ID) references instructor on delete cascade teaches (ID CREATE TABLE student varchar(5), name varchar(20) not null, dept_name varchar(20), tot_cred numeric(3,0) check (tot_cred > primary key (ID), foreign key (dept_name) references department on delete set null student 0), CREATE TABLE takes (ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric (4,0), grade varchar(2), primary key (ID, course_id, sec_id, semester, year), foreign key (course_id, sec_id, semester, year) references section on delete cascade, foreign key (ID) references student on delete cascade takes CREATE TABLE advisor (S_ID varchar(5), i_ID varchar(5), primary key (S_ID), foreign key (i_ID) references instructor (ID) on delete set null, foreign key (S_ID) references student (ID) on delete cascade advisor time_slot CREATE TABLE time_slot (time_slot_id varchar(4), day varchar(1), start_hr numeric (2) check (start_hr >= 0 and start_hr = 0 and start_min = 0 and end_hr = 0 and end_min 0), primary key (dept_name) CREATE TABLE course (course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) check (credits > 0), primary key (course_id), foreign key (dept_name) references department on delete set null course (ID CREATE TABLE instructor varchar(5), name varchar(20) not null, dept_name varchar(20), instructor salary numeric(8,2) check (salary > 29000), primary key (ID), foreign key (dept_name) references department on delete set null CREATE TABLE section (course_id varchar(8), sec_id varchar(8), semester varchar(6) check (semester in ('Fall', 'Winter', 'Spring', 'Summer')), year numeric(4,0) check (year > 1701 and year 2100), building varchar(15), room_number varchar(7), time_slot_id varchar(4), primary key (course_id, sec_id, semester, year), foreign key (course_1d) references course on delete cascade, foreign key (building, room_number) references classroom on delete set null section CREATE TABLE teaches (ID varchar(5) course_id varchar(8) sec_id varchar(8), semester varchar(6), year numeric (4,0), primary key (ID, course_id, sec_id, semester, year), foreign key (course_id, sec_id, semester, year) references section on delete cascade, foreign key (ID) references instructor on delete cascade teaches (ID CREATE TABLE student varchar(5), name varchar(20) not null, dept_name varchar(20), tot_cred numeric(3,0) check (tot_cred > primary key (ID), foreign key (dept_name) references department on delete set null student 0), CREATE TABLE takes (ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric (4,0), grade varchar(2), primary key (ID, course_id, sec_id, semester, year), foreign key (course_id, sec_id, semester, year) references section on delete cascade, foreign key (ID) references student on delete cascade takes CREATE TABLE advisor (S_ID varchar(5), i_ID varchar(5), primary key (S_ID), foreign key (i_ID) references instructor (ID) on delete set null, foreign key (S_ID) references student (ID) on delete cascade advisor time_slot CREATE TABLE time_slot (time_slot_id varchar(4), day varchar(1), start_hr numeric (2) check (start_hr >= 0 and start_hr = 0 and start_min = 0 and end_hr = 0 and end_minStep 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