Concept explainers
- Consider the following relational schema and answer the following questions.
User (email, name, address, householdSize)
a. Express in relational algebra the query that finds all pairs of users where the two people both claim to have a household size 2 and have the same address and returns their names and the common address.
b. Express the above query in SQL.
c. Write in SQL the query that finds the users whose household size is at least 50% more than the average household size and returns their name and household size, sorted by household size. (Hint: decompose the problem into sub-problems, and you may use a view to capture an intermediate result.)
d. Write in SQL the query that finds all users each having a household size different from the total number of users having the same address as him or her. (Hint: again, decompose the problem into sub-problems, and you may use a view to capture a intermediate result.)
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Question: Which colleges offer courses? (Change the SQL query to an relational algebra query.) **Please show the resulting tuples output based on your answer as well in a table for further explanation. ** SELECT COURSE.COLLEGE FROM COURSE, DEPARTMENT WHERE COURSE.DCODE = DEPARTMENT.DCODE;arrow_forwardAll parts of this question use the following database schema: Flights(flno, from, to, distance) Aircraft(aid, aname, cruisingrange) Certified(eid, aid) Employees(eid, ename, salary) c) For each cruisingrange held by at least 3 aircraft, give the lowest salary of employees certified to fly one of those aircraft. Express in SQL only:arrow_forward1) Find names of those departments, each of which has at least two same-aged employees. 2)List names of those departments each of which has an employee named ‘Joe’. 3)List the names of employees, each of whom has salary more than the budget of the department he/she works in. Answer the above questions in relational algebra with reference to the following relational schema. Key fields are bold. Emp (eid:integer, ename:string, age:integer, salary:real)Works (eid:integer, did:integer, pct_time:integer)Dept (did:integer, dname:string, budget:real)arrow_forward
- We have a relational database that contains the table ‘Staff’. The table ‘Staff’ consist of columns ‘Name’, ‘Department’ and ‘Date of Joining’. What query would you use to extract the Names and Department of all staff in the table? a. SELECT * FROM Staff b. a) SELECT Name, Department FROM Staff c. SELECT Name, Department IN Staff d. SELECT * IN Staffarrow_forward(b) Consider the schema of Customer table and write SQL statements for the following queries. sid sname address age occupation salary Pavment mode gender 123 sam yacoas 31 manager 60000 cash 124 david flaca 38 administrator 45000 credit i. Write the SQL query to set salary of all supervisors to Rs 40 000. ii. Write the SQL query to display details of clients whose names end with character 'e'. iii. Write the SQL code to display details of those clients who come from Vacoas or mahebourg,arrow_forwardRelational Algebra Questions:Using the instance of the Airport database, formulate the following queries in the relationalalgebra: 1. List full details of all airports located outside the United States.Note: You should use the not equal sign in this query. 2. List the name and the state of all United States airports. 3. List the name and the fleet size of all carriers employing more than 50000 workers. 4. List the carrier name, the carrierID, the flightNo and the date of all flights. 5. Display the number of airports. 6. Display the number of flights with distances longer than 3000 miles. 7. Display the number of all carriers and the average of their revenues. 8. Display the number of flights leaving from JFK and the total of their distances. 9. Display the minimum, the average, and the maximum distances of the flights that arescheduled on October 17th, 2017?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education