Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following relational schema: Department(deptid, dname, location) Student(snum, sname, deptid, age) Faculty (fid, fname, deptid) Class(cname, deptid meets_at, room, faculty) Enrolled(snum, cname, score, grade)

image text in transcribed

image text in transcribed

Consider the following relational schema: Department(deptid, dname, location) Student(snum, sname, deptid, age) Faculty (fid, fname, deptid) Class(cname, deptid meets_at, room, faculty) Enrolled(snum, cname, score, grade) Assume that: All students and faculty members must major/work in one depart- ment; - aculty teach courses only in the department they belong to; The names of the courses are unique for each department; Scores are numbers in [0,100]; Faculty in Table Class is a subset of fid in Table Faculty. .Write each of the following queries using Query-by-Example (QBE). If you believe any one of the following is not expressible in QBE, informally ex plain why it cannot be expressed. 1. (15 pts) Print the names of the department(s) that have more courses than the CS department(deptid-101) 2. (10 pts) Print the ids and names of the students along with their scores and grades in each course they have enrolled. 3. (15 pts) Print the names of the faculty members who instruct at least two courses. 4. (10 pts) Print the names of the students who are enrolled in the most number of courses 5. (10 pts) Print the student ids with the maximum average score in the courses they have enrolled in. 6. (5 pts) Delete the departments that do not have any faculty or courses at all Write each of the following queries using Datalog. If you believe any one of the following is not expressible in Datalog, informally explain why it can- not be expressed 7. (10 pts) Find the faculty who have instructed at least one course in the CS department but have never instructed any course in the Math- ematics department. 8. (10 pts) Find the names of courses each student gets the lowest score in, i.e., if a student takes 2 courses A and B and scores 50 and 60, respectively, then A is the name of the course in which that stu- dent (can be different for different students depending on their score) has scored the lowest. 9. (15 pts) What are the possible outcomes if a Datalog rule is unsafe? Please illustrate two different scenarios for this case by designing un- safe rules for the relational schema mentioned above, and explain the answers to these rules. Consider the following relational schema: Department(deptid, dname, location) Student(snum, sname, deptid, age) Faculty (fid, fname, deptid) Class(cname, deptid meets_at, room, faculty) Enrolled(snum, cname, score, grade) Assume that: All students and faculty members must major/work in one depart- ment; - aculty teach courses only in the department they belong to; The names of the courses are unique for each department; Scores are numbers in [0,100]; Faculty in Table Class is a subset of fid in Table Faculty. .Write each of the following queries using Query-by-Example (QBE). If you believe any one of the following is not expressible in QBE, informally ex plain why it cannot be expressed. 1. (15 pts) Print the names of the department(s) that have more courses than the CS department(deptid-101) 2. (10 pts) Print the ids and names of the students along with their scores and grades in each course they have enrolled. 3. (15 pts) Print the names of the faculty members who instruct at least two courses. 4. (10 pts) Print the names of the students who are enrolled in the most number of courses 5. (10 pts) Print the student ids with the maximum average score in the courses they have enrolled in. 6. (5 pts) Delete the departments that do not have any faculty or courses at all Write each of the following queries using Datalog. If you believe any one of the following is not expressible in Datalog, informally explain why it can- not be expressed 7. (10 pts) Find the faculty who have instructed at least one course in the CS department but have never instructed any course in the Math- ematics department. 8. (10 pts) Find the names of courses each student gets the lowest score in, i.e., if a student takes 2 courses A and B and scores 50 and 60, respectively, then A is the name of the course in which that stu- dent (can be different for different students depending on their score) has scored the lowest. 9. (15 pts) What are the possible outcomes if a Datalog rule is unsafe? Please illustrate two different scenarios for this case by designing un- safe rules for the relational schema mentioned above, and explain the answers to these rules

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions