Question

In: Computer Science

1. Consider the following relations. The primary keys are underlined. All attributes are of type string...

1. Consider the following relations. The primary keys are underlined. All attributes are of type string if not indicated otherwise.

 Student(s_ID, s_name, s_degree: integer, advisorID, d_ID)

 Lecture(l_ID, l_name,l_degree: integer, p_ID, d_ID)

 Register(s_ID,l_ID,score: integer, Semester)

 Professor(p_ID,p_name, d_ID)

 Department(d_ID, d_name, address)

a. Find the names of professors who have taught in every semester.

b. List the names of lectures that the CISE department offers but that are taught by a professor whose department is not CISE.

c. Find the names of students who got the highest score in the lecture ‘Databases’.

d. Find the names of students who have registered every lecture of the CISE department.

e. Find the names of students who got more than 90 in the ‘DB’ lecture and less than 70 in the ‘Algorithm’ lecture.

Solutions

Expert Solution

a. SELECT Professor.p_ID,Professor.p_name,Register.Semester FROM Lecture INNER JOIN Register ON Lecture.l_ID = Register.l_ID INNER JOIN Professor ON Professor.p_ID = Lecturer.p_ID

b. SELECT Lecture.l_ID,Lecturer.l_name FROM Lecturer INNER JOIN Professor ON Lecturer.p_ID = Professor.p_ID INNER JOIN Department ON Department.d_ID = Professor.d_ID GROUP BY Lecturer.l_name HAVING Department.d_name = 'CISE'

c.SELECT Student.s_ID,Student.s_name,Max(Register.score) FROM Student INNER JOIN Register ON Student.s_ID = Register.s_ID INNER JOIN Lecture ON Lecture.l_ID = Register.l_ID

d. SELECT Student.s_ID,Student.s_name FROM Student INNER JOIN Lecture ON Student.d_ID = Lecture.d_ID INNER JOIN Department ON Department.d_ID = Student.d_ID WHERE Department.d_name = 'CISE'

e. SELECT Student.s_ID,Student.s_name FROM Student INNER JOIN Lecture ON Student.d_ID = Lecture.d_ID INNER JOIN Register ON Student.s_ID = Register.s_ID WHERE Register.score > 90 AND Lecture.l_degree = 'DB' OR Register.score < 70 AND Lecture.l_degree = 'Algorithm' GROUP BY Student.s_ID


Related Solutions

Consider the following relational schema about a University (the primary keys are underlined and foreign keys...
Consider the following relational schema about a University (the primary keys are underlined and foreign keys are italic) STUDENT(StudentID, name, major, year, age) CLASS(ClassName, meetsAt, room, LecturerID) ENROLLED(StudentID, ClassName, mark) LECTURER(LecturerID, name, DepartmentID) DEPARTMENT(DepartmentID, name) Write the SQL statements for the following query: B1. Find the age of the oldest student. B2. Find the ID’s of lecturers whose name begins with “K” \ B3. Find the age of the youngest student who is enrolled in Mechatronics. B4. Find the age...
SQL ONLY. WRITE CLEAR AND CORRECT ANSWERS. Consider the following relations (PRIMARY KEYS ARE WRITTEN IN...
SQL ONLY. WRITE CLEAR AND CORRECT ANSWERS. Consider the following relations (PRIMARY KEYS ARE WRITTEN IN BOLD) departments (dept_no, dept_name) dept_emp (emp_no, dept_no, from_date, to_date) dept_manager (dept_no, emp_no, from_date, to_date) employees (emp_no, birth_date, first_name, last_name, gender, hire_date) salaries (emp_no, salary, from_date, to_date) titles(emp_no, title, from_date, to_date) Write the following queries in SQL. No duplicates should be printed in any of the answers. List all the titles for which there is at least one employee having the title. Find the current...
SQL ONLY. WRITE CLEAR AND SIMPLE ANSWERS. Consider the following relations (PRIMARY KEYS ARE WRITTEN IN...
SQL ONLY. WRITE CLEAR AND SIMPLE ANSWERS. Consider the following relations (PRIMARY KEYS ARE WRITTEN IN BOLD) departments (dept_no, dept_name) dept_emp (emp_no, dept_no, from_date, to_date) dept_manager (dept_no, emp_no, from_date, to_date) employees (emp_no, birth_date, first_name, last_name, gender, hire_date) salaries (emp_no, salary, from_date, to_date) titles(emp_no, title, from_date, to_date) Write the following queries in SQL. No duplicates should be printed in any of the answers. List all the titles for which there is at least one employee having the title. Find the current...
Normalize the following relations. Show possible candidate/primary keys and the functional dependencies. Explain the normal form...
Normalize the following relations. Show possible candidate/primary keys and the functional dependencies. Explain the normal form in which the relation is currently in (based on the sample data) and how do you break the relations to get 3rd Normal Form. Show the new relations obtained after normalization and underline the candidate/primary key in each new relation and italic the foreign key. Relation 1: COLLEGE PARKING TICKET (STID, LName, FName, PhoneNo, StateLic, LicNo, Ticket#, Date, Code, Fine) (Illustrated with sample data)...
Question (3) Consider the following relations: Student(snum: integer, sname: string, major: string, level: string, age: integer)...
Question (3) Consider the following relations: Student(snum: integer, sname: string, major: string, level: string, age: integer) Class(name: string, meets at: string, room: string, fid: integer) Enrolled(snum: integer, cname: string) Faculty(fid: integer, fname: string, deptid: integer) The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair such that the student is enrolled in the class. Write the following queries in Oracle SQL. No duplicates should be printed in any of the answers. i) (2 points)...
1. For each of the following statements, define all of the underlined terms. Then, explain why...
1. For each of the following statements, define all of the underlined terms. Then, explain why the statement is true, false or uncertain. (a) If a consumer views two goods as perfect substitutes then their optimal choice will be a corner solution. (b) The substitution effect from a price increase states that the consumer will always choose a smaller amount of that good to consume. However, the income effect states that consumption can move in either direction. (c) Suppose Alf...
Consider the following three tables, primary and foreign keys. Table Name        SalesPeople Attribute Name                  &nbsp
Consider the following three tables, primary and foreign keys. Table Name        SalesPeople Attribute Name                                Type                                      Key Type EmployeeNumber             Number                               Primary Key Name                                   Character JobTitle                                  Character            Address                                 Character PhoneNumber                     Character YearsInPosition                             Number Table Name        ProductDescription Attribute Name                                Type                                      Key Type                 ProductNumber                Number                               Primary Key                 ProductName                  Character                            ProductPrice                   Number Table Name        SalesOrder Attribute Name                                Type                                      Key Type                 SalesOrderNumber        Number                               Primary Key                 ProductNumber               Number                               Foreign Key                 EmployeeNumber           Number                               Foreign Key                 SalesOrderDate                Date Assume that you...
Add the following private attributes: String publisher String title String ISBN String imageName double price Create...
Add the following private attributes: String publisher String title String ISBN String imageName double price Create getter/setter methods for all data types Create a constructor that takes in all attributes and sets them Remove the default constructor Override the toString() method and return a String that represents the book object that is formatted nicely and contains all information (attributes) In the main class: Create a main method that throws FileNotFoundException Import java.io libraries Import java.util.Scanner Create a loop to read...
PYTHON PLEASE: Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string,...
PYTHON PLEASE: Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string, default is ‘Normal’) self.current_hp (int, starts out equal to max_hp) self.max_hp (int, is given as input when the class instance is created, default is 20) self.exp (int, starts at 0, is increased by fighting) self.attacks (a dict of all known attacks) self.possible_attacks (a dictionary of all possible attacks) The dictionary of possible_attacks will map the name of an attack (the key) to how many...
Model the following cases by ER diagrams. Identify the keys, attributes and relationship cardinalities, and convert...
Model the following cases by ER diagrams. Identify the keys, attributes and relationship cardinalities, and convert them into table schemas. Provide necessary assumptions to support your model. The following descriptions are about the inventory information. a) Each product item has ID, description, quantity in the inventory, unit price and a supplier. b) Suppliers have unique ID, addresses, phone numbers, and names. c) Each address is made up of a street address, a city, and a postcode. d) The purchase order...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT