Question

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 employees is great than $28,000. [1 mark] C3. List the name and salary of the managers with no more than 10 employees. [2 marks] C4. List the names of the employees who earn more than any employee in the Deliver department. [2 mark

Homework Answers

Answer #1

SOLUTION :

1.

Select Item.ItemName from Item inner join Sale on Items.ItemName = Sale.ItemName inner join Department on Sale.DeptName = Department.DeptName where DeptFloor = 1 or DeptFloor = 2;

2.

Select Department.DeptName , Avg(EmpSalary) from Department inner join Employee on Department.DeptName = Employee.DeptName group by Department.DeptName having Avg(EmpSalary) > 28000;

3.

Select M.EmpFname, M.EmpSalary from Employee M inner join Employee E on M.EmpNo = E.SupervisedBy group by M.EmpFname, M.EmpSalary having Count(E.EmpNo) <= 10;

4.

Select EmpFname from Employee where EmpSalary > Any (Select EmpSalary from Employee where DeptName = 'Delivery');

Know the answer?
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
Similar Questions
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 of...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN,...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN, ENAME, EADDRESS, SEX, DATE_OF_BIRTH, SUPERVISOR, DNR) S U P E R V I S O R : foreign key refers to SSN in EMPLOYEE, NULL value allowed D N R : foreign key refers to DNR in DEPARTMENT, NULL value not allowed DEPARTMENT(DNR, DNAME, DLOCATION, MGNR) MGNR: foreign key refers to SSN in EMPLOYEE, NULL value not allowed PROJECT(PNR, PNAME, PDURATION, DNR) DNR: foreign...
Relational Algebra (50 pts): Consider the following database schema that keeps track of Sailors, Boats and...
Relational Algebra (50 pts): Consider the following database schema that keeps track of Sailors, Boats and the boats reserved by sailors. Sailors(sid, sname, rating, age) Boatsbid, bname, color) Reserves(sid, bid, date) Keys are underlined in each relation. Specify the following queries in Relational Algebra using above database schema. (f) find the name of sailors with the highest rating (g) find the name and age of oldest sailors (h) find the age of youngest sailor for each rating level (i) find...
Give the relational algebra, tuple calculus, and SQL expressions for each using the below schema: SPERSON(EmpID,...
Give the relational algebra, tuple calculus, and SQL expressions for each using the below schema: SPERSON(EmpID, Name, Dept) TRIP(TripID, EmpID, ToCity, StartDate, EndDate) EXPENSE(ExpID, TripID, AccountID, Amount) a) List the names and employee ID of a salesperson. b) List employee ID and employee names that took a trip(s) to Charleston city. c) List the names of all employees who have spent more than $500 on their trip. d) List employees' names and their IDs that have never taken a trip....
Using the Company database in Oracle, construct SQL queries for the following (note: I will make...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make the files to create and populate the Company database available on Isadore shortly): List the last name and address of managers who have a dependent with the same first name as themselves. Retrieve the names of all employees who are directly supervised by ‘Franklin Wong’. Retrieve the names of employees in the Research department who work more than 20 hours per week on the...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year,...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year, Price) (P# is the primary key) Customer( C#, CName, City) (C# is the primary key) Supply(S#, P#, C#, Quantity, Amount, Date) (S# is the primary key) Query: For each Apple product supplied to more than 10 different customers in Chicago in 2020, list product number, product name, total supply quantity, and total supply amount. Sort the result by product name.
1. Consider the following tables in a relational database. Provide the appropriate "SELECT" SQL statement necessary...
1. Consider the following tables in a relational database. Provide the appropriate "SELECT" SQL statement necessary to answer the queries that follow. Primary keys are underlined and foreign key fields have an asterisk at the end of the field. CUSTOMERS (CUST-NO, C-NAME, C-ADDRESS, BALANCE) SALESPERSONS (SP-NO, S-NAME, DATE-EMPLOYED, SALARY) SALES (INVOICE-NO, DATE, CUST-NO*, SP-NO*) a) List the salesperson name and salary for all sales to customers whose balance outstanding is greater than 20000. b) List the names and addresses of...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode)...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). A research field...
Specify the following queries in SQL on the COMPANY database. Show the result of each query....
Specify the following queries in SQL on the COMPANY database. Show the result of each query. Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. List the names of all employees who have a dependent with the same first name as themselves. Find the names of all employees who are directly supervised by ‘Franklin Wong’. Specify the following updates using the SQL update commands. Show the state of...
Consider a relational DBMS that has two relations: Emp (employees) and Dept (departments).    Emp(id, name,...
Consider a relational DBMS that has two relations: Emp (employees) and Dept (departments).    Emp(id, name, age, salary, dname)    Dept(dname, location) - The Emp table has 500 tuples, and each tuple has a fixed length of 500 bytes. The primary key attribute "id" has a length of 40 bytes. - The Dept table has 100 tuples, and each tuple has 200 bytes. The primary key attribute "dname" has a length of 20 bytes. For simplicity, we assume each employee...