Question

In: Computer Science

Consider the following relational schema: student(studID, studname, major, advisor) department(deptname, major) club(studID,clubname) professor(profID, profname, building, deptname)...

Consider the following relational schema:

student(studID, studname, major, advisor)

department(deptname, major)

club(studID,clubname)

professor(profID, profname, building, deptname)

NOTE: KEY ATTRIBUTES ARE IN BOLD

where advisor takes values in the domain of professor names (profname) and

the underline attributes form the primary key of the corresponding relations.

Questions:

  1. State any assumptions you might make.
  2. Write the relational algebra for the following queries:

2.a. Find all students and their advisors.

2.b. Find all the students who are in any one of the clubs that Jamie Smith is in.

2.c. Find all of the advisors, their buildings and departments that advise students that

are in the same clubs that Jamie Smith participates into.

2.d. Find all professors names and their departments that have offices in the

buildings identified in query 2c.

2.e. Find all student names and their major(s) that participate in Computer Science

Association Club.

Solutions

Expert Solution

2.a. Find all students and their advisors.

select studname,advisor from student;

2.b. Find all the students who are in any one of the clubs that Jamie Smith is in.

select s.studname
from student s, club c
where s.studID = c.studID
and c.clubname in (select c.clubname
from student s, club c
where s.studID = c.studID
and studname = 'Jamie Smith');

2.c. Find all of the advisors, their buildings and departments that advise
students that are in the same clubs that Jamie Smith participates into.

select s.advisor, p.building, d.deptname
from student s, club c, department d , professor p
where s.studID = c.studID
and s.advisor = p.profname
and p.deptname = d.deptname
and s.major = d.major
and c.clubname in (select c.clubname
from student s, club c
where s.studID = c.studID
and studname = 'Jamie Smith');


2.d. Find all professors names and their departments that have offices in the
buildings identified in query 2c.


select p.profname, p.deptname
from professor p where profID in
(select p.profID
from student s, club c, department d , professor p
where s.studID = c.studID
and s.advisor = p.profname
and p.deptname = d.deptname
and s.major = d.major
and c.clubname in (select c.clubname
from student s, club c
where s.studID = c.studID
and studname = 'Jamie Smith'));


2.e. Find all student names and their major(s) that participate in Computer Science

Association Club.

select s.studname, s.major
from student s, club c
where s.studID = c.studID
and c.clubname = 'Computer Science Association Club';


Related Solutions

Consider the following relational schema: student(studID, studname, major, advisor) department(deptname, major) club(studID,clubname) professor(profID, profname, building, deptname)...
Consider the following relational schema: student(studID, studname, major, advisor) department(deptname, major) club(studID,clubname) professor(profID, profname, building, deptname) NOTE: KEY ATTRIBUTES ARE IN BOLD where advisor takes values in the domain of professor names (profname) and the underline attributes form the primary key of the corresponding relations. Questions: State any assumptions you might make. Write the relational algebra for the following queries: 2.a. Find all students and their advisors. 2.b. Find all the students who are in any one of the clubs...
1- Paper evaluation scenario a) Draw an ERD for the following relational schema: STUDENT (STD_ID, STD_First_Name,...
1- Paper evaluation scenario a) Draw an ERD for the following relational schema: STUDENT (STD_ID, STD_First_Name, STD_Last_Name, STD_Admit_Semester, STD_Admit_Year, STD_Enroll_Status) PAPER (PP_ID, PP_Title, PP_Submit_Date, PP_Accepted, PP_Type) The two entities are related with the following business rule: • Each student may write many papers Explain your choice of minimum and maximum cardinalities. b) Extend the existing ERD with an EVALUATOR entity. The job of the evaluator is to grade each paper. The following business rules apply: • Each paper is evaluated...
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...
Question 2: consider the following library relational database schema Write a program segment to retrieves the...
Question 2: consider the following library relational database schema Write a program segment to retrieves the list of books that became overdue yesterday and that prints the book title and borrower name for each. 1- Use JDBC with Java as the host language
Consider the following relational schema (the primary keys are underlined and foreign keys are italic) ITEM(ItemName,...
Consider the following relational schema (the primary keys are underlined and foreign keys are italic) ITEM(ItemName, ItemType, ItemColour) DEPARTMENT(Deptname, DeptFloor, DeptPhone, Manager) EMPLOYEE(EmpNo, EmpFname, EmpSalary, DeptName, SupervisedBy) SUPPLIER(SupNo, SupName) SALE(SaleNo, SaleQty, ItemName, DeptName) DELIVERY(DeliNo, DeliQty, ItemName, DeptName, SupNo) Write the SQL statements for the following queries: C1. Find the names of items sold on first and second floors. [1 mark] C2. For each department, list the department name and average salary of the employees where the average salary of the...
Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-
Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-id, company-id, salary)             company(company-name, company-id, c-city)             manages(employee-id, manager-id) Specify the following queries on this database schema using the relational operators we discussed in class. Write your answers on a separate sheet of paper in the order that they are specified below. Retrieve the name and address of employees who work for First Bank Corporation. Retrieve the name, street address, and city of residence of all employees...
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Create an ER diagram, a Relational Schema, and tables with Data, based on the following requirements:...
Create an ER diagram, a Relational Schema, and tables with Data, based on the following requirements: The database will keep track of students and campus organizations. - For each student, we will keep track of his or her unique student ID, and his or her name and gender. - For each organization, we will keep track of its unique organization ID and the location. - Each student in the database belongs to at least one organization and can belong to...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName,...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName, LastName, Year) Takes (Username, Department, Number, Term, Grade) [clarification] In Student, Year is an integer. A student can be a 2nd year student. In that case, Year value would be 2. For the Takes relation: ·         Grade is NA for current semester students ·         Username is foreign key to Student ·         (Department, Number, Term) is foreign key to Class a)       Write an SQL query that returns the Term...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT