Question

Consider the following relations: Pupil(student Num Integer, studentName: String, Degree: String, Year: String, Age: Integer) Course(course Name: String, classTime: String, classroom: String, facultylD: Integer) Registered(student Num: Integer.courseName: String) Faculty(facultyID: Integet, faculty Name: String, departmentid: Integer) Attributes of the Pupil relation The student number is an 8 digit code, for example, 98712201. The student name is a combination of the first and last name, for example, Mary Jane. The degree option can be any program offered by the university, for example, Physies or Mathematics. Year has values: Y1 (year 1), Y2 (year 2) or Y3 (year Attributes of the Course relation: Course name is a 5 digit code, for example, CS11A or MS10A. Class time is a 15 digit string, for example, 09:00AM-11:00AM. Classroom names are a letter followed by three digits, for example, A123 The faculty ID is a 4 digit code, for example, 1001 (Natural Sciences). Attributes of the Registered relation: The student number is as described in the Pupil relation. The course name is as described in the Course relation Note: Registered has one record per pupil-course pair such that the pupil is registered in the course. Attributes of the Faculty relation: The faculty ID is as described in the Course relation. The faculty name is a 6 letter code, for example, Nat Sci (Natural Sciences). The department ID is a 5 digit code, for example, 12345.FACULTY RELATION REPLACED WITH TEACHER ; FACULTYID REPLACED WITH TEACHERID ; FACULTYNAME REPLACED WITH TEACHERNAME

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

-- 4)

SELECT DISTINCT P.studentName

FROM Pupil P

WHERE P.studentNum IN (

SELECT R1.studentNum

FROM Registered R1, Registered R2, Course C1, Course C2

WHERE R1.studentNum = R2.studentNum AND R1.courseName <> R2.courseName

AND R1.courseName = C1.courseName

AND R2.courseName = C2.courseName AND C1.classTime = C2.classTime)

-- 5.

SELECT DISTINCT T.teacherID

FROM Teacher T

WHERE NOT EXISTS (

( SELECT * FROM Course C) EXCEPT

(SELECT C1.classroom

FROM Course C1

WHERE C1.teacherID = T.teacherID)

);

--6)

SELECT DISTINCT T.teacherName

FROM Teacher T

WHERE 5 > (

SELECT COUNT (R.studentNum)

FROM Course C, Registered R

WHERE C.courseName = R.courseName

AND C.teacherID = T.teacherID

);

-- 7.

SELECT P.Year, AVG(P.Age)

FROM Pupil P

GROUP BY P.Year;

-- 8.

SELECT P.Year, AVG(P.Age)

FROM Pupil P

WHERE P.Year <> 'Y1'

GROUP BY P.Year;

-- 9.

SELECT T.teacherName, COUNT(*) AS CourseCount

FROM Teacher T, Course C

WHERE T.teacherID = C.teacherID

GROUP BY T.teacherID, T.teacherName

HAVING EVERY(C.classroom = 'J341');

-- 10.

SELECT DISTINCT P.studentName

FROM Pupil P

WHERE P.studentNum IN (

SELECT R.studentNum

FROM Registered R

GROUP BY R.studentNum

HAVING COUNT (*) >= ALL (

SELECT COUNT (*)

FROM Registered R2

GROUP BY E2.studentNum)

);

-- 11.

SELECT DISTINCT P.studentName

FROM Pupil P

WHERE P.studentNum NOT IN (

SELECT R.studentNum

FROM Registered R

);

-- 12.

SELECT P.Age, P.Year

FROM Pupil P

GROUP BY P.Age, P.Year

HAVING P.Year IN (

SELECT S1.Year FROM Pupil P1

WHERE S1.Age = P.Age

GROUP BY S1.Year, S1.Age

HAVING COUNT (*) >= ALL (

SELECT COUNT (*)

FROM Pupil P2

WHERE s1.Age = S2.Age

GROUP BY S2.Year, S2.Age

)

);

Add a comment
Know the answer?
Add Answer to:
FACULTY RELATION REPLACED WITH TEACHER ; FACULTYID REPLACED WITH TEACHERID ; FACULTYNAME REPLACED WITH TEACHERNAME Consider...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assume that the takes relation has not yet been defined. Give an SQL statement that adds...

    Assume that the takes relation has not yet been defined. Give an SQL statement that adds the takes relation to the database. Assume that: •Id is an integer •course_id is a string of up to10 characters. •sec_id should be a non-negative integer. •the semester is a one-character field, equal to either ‘F’ or ‘S’, and the •year is an integer. •grade can be null, but if not, it should be a letter in the string ‘ABCDF’. Your statement must ensure...

  • Last picture is the tester program! In this Assignment, you will create a Student class and...

    Last picture is the tester program! In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...

  • what is the solution for this Java problem? Generics Suppose you need to process the following...

    what is the solution for this Java problem? Generics Suppose you need to process the following information regarding Students and Courses: A Student has a name, age, ID, and courseList. The class should have a constructor with inputs for setting name, ID and age. The class should have setters and getters for attributes name, ID and age, and a method addCourse, removeCourse, printSchedule. courseList: use the generic class ArrayList<E> as the type of this attribute addCourse: this method takes as...

  • Create a java class for an object called Student which contains the following private attributes: a...

    Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....

  • Consider the following set of requirements for a university database that is used to keep track...

    Consider the following set of requirements for a university database that is used to keep track of students' transcripts The university keeps track of each student's name, student number, social security number, address and phone, birthdate, gender, `, and degree program (bachelor, Masters, PhD.). Both social security number and student number have unique values for each student. Each department is described by a name, department code, office number, office phone. Both name and code have unique values for each department....

  • PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class...

    PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...

  • Question 1: University Database Consider the following set of requirements for a UNIVERSITY database that is...

    Question 1: University Database Consider the following set of requirements for a UNIVERSITY database that is used to keep track of students' transcripts. The university keeps track of each student's name, student number, social security number current address and phone, permanent address and phone, birth date, sex, class (freshman, sophomore,., graduate), major department, minor department (if any), and degree program (B.A., B.S.,..., Ph.D.). Some user applications need to refer to the city, state, and zip of the student's permanent address,...

  • Problem 1 Consider the following set of requirements for a university database that is used to...

    Problem 1 Consider the following set of requirements for a university database that is used to keep track of students' transcripts. (a) The university keeps track of each student's name, student number, social security number, current address and phone, permanent address and phone, birthdate, sex, class (freshman, sophomore, -, graduate), major department, minor department (if any), and degree program (B.A., B.S., ...., Ph.D.). Some user applications need to refer to the city, state, and zip of the student's permanent address,...

  • For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of...

    For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of A2 Student class demo ') s1 = Student('David Miller', major = 'Hist',enrolled = 'y', credits = 0, qpoints = 0) s2 = Student('Sonia Fillmore', major = 'Math',enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('A. Einstein', major = 'Phys',enrolled = 'y', credits = 0, qpoints = 0)          s4 = Student('W. A. Mozart', major = 'Mus',enrolled = 'n', credits = 29, qpoints...

  • Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in...

    Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in which players construct words from random letters, building on words already played. Each letter has an associated point value and the aim is to collect more points than your opponent. Please see https: //en.wikipedia.org/wiki/Scrabble for an overview if you are unfamiliar with the game. You will write a program that allows a user to enter 7 letters (representing the letter tiles they hold), plus...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT