Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP 3413-FA: Database Management Systems

Assignment-3

Fall, 2022

Problem Description

Using the university schema, write the following queries.  In some cases you need to insert extra data to show the effect of a particular feature this is indicated with the question. You should then show not only the query, but also the insert statements to add the required extra data.

1. Find the maximum and minimum enrollment across all sections, considering only sections that had some enrollment, don’t worry about those that had no students taking that section.

2. Find all sections that had the maximum enrollment (along with the enrollment), using a subquery.

3. As in in Q1, but now also include sections with no students taking them; the enroll- ment for such sections should be treated as 0. Do this in two different ways (and create require data for testing) a) Using a scalar subquery b) Using aggregation on a left outer join (use the SQL natural left outer join syntax).

4. Find all courses whose identier starts with the string "CS-1".

5. Find instructors who have taught all the above courses a) Using the "not exists ... except ..." structure and b) Using matching of counts which we covered in class (don’t forget the distinct clause!).

6. Insert each instructor as a student, with tot_creds = 0, in the same department.

7. Now delete all the newly added "students" above (note: already existing students who happened to have tot_creds = 0 should not get deleted).

8. Update the salary of each instructor to 10000 times the number of course sections they have taught.

9. Create a view CSinstructors, showing all information about instructors from the Comp. Sci. department.

10. Grant permission to a particular student to view all data in your student relation.

What to submit?

 The SQL queries

The output/screenshots of running the SQL queries.

Notes

• Submit a single pdf le containing answers to the above problems and rename the file as follows: YourLastName_YourFirstName_A-3.pdf.

Upload the le on the course website by the deadline.