Consider a database with the following schema:
| Person ( name, age, gender ) | name is a key |
| Frequents ( name, pizzeria ) | (name, pizzeria) is a key |
| Eats ( name, pizza ) | (name, pizza) is a key |
| Serves ( pizzeria, pizza, price ) | (pizzeria, pizza) is a key |
Write SQL clauses for the queries given:
| e. | Find all pizzerias that are frequented by only females or only males. |
| f. | For each person, find all pizzas the person eats that are not served by any pizzeria the person frequents. Return all such person (name) / pizza pairs. |
| g. | Find the names of all people who frequent only pizzerias serving at least one pizza they eat. |
| h. | Find the names of all people who frequent every pizzeria serving at least one pizza they eat. |
| i. | Find the pizzeria serving the cheapest pepperoni pizza. In the case of ties, return all of the cheapest-pepperoni pizzerias. |
E) select pizzeria from Frequents where person.gender ='Male' OR person.gender ='Female'
F)
Consider a database with the following schema: Person ( name, age, gender ) name is a...
Consider a database with the following schema.BARS(name,license,city,phone,addr);BEERS(name,manf);DRINKERS(name,city,phone,addr);LIKES(drinker,beer); FREQUENTS(drinker,bar); SELLS(bar,beer,price); Return SQL code for the following queries.1. Find all distinct drinkers whose phone numbers come from area code 917 and who like Budweiser or Bud (synonim!)2. What beers does Mike like?3. Which town has the most drinkers?4. What bars are frequented by drinkers from that town (3)?5. Provide all bars which serve beers that Mike likes6. Who likes the at least one same beer that Joe or Mike like?7. All bars...
Consider a database with the following schema. LIKES(drinker,beer); /* key: all columns */ FREQUENTS(drinker,pub); /* key: all columns */ SERVES(pub,beer,cost); /* key: (pub,beer) */ Write the following queries in relational algebra. You can use the math notation (greek letters sigma, pi, etc.) or the ASCii "linear" notation I used in class. In order to make things more clear, please use intermediate results defined with the assignment notation in the algebra: R(a,b) := <rel-alg expression>. Try to give meaningful names for...
Relational algebra pls. Appreciate it!(Queries are
detailed)
Consider the following relational database that stores information about bars and customers: Drinker (name, address) Bar (name, address) Beer (name, brewer) Frequents (drinker, bar, times a week) Likes (drinker, beer) Serves (bar, beer, price) Write the following queries in relational algebra: (5 points) Find all drinkers who frequent only those bars that serve some beers they like. 5 points) Find all drinkers who frequent every bar that serves some beers they like (10...
1. Given the following database schema owner(owner_name, age) owns(owner_name, num_cats) Write relational algebra for the following: Find the name of all owners above the age of 50 Find the name of all owners who own fewer than 5 cats Find the name of all owners who are below the age of 24 and own more than 4 cats 2. Given the following database schema person(name, age, account_id) account(account_id, balance) Write a relational algebra for the following Find the name of...
Please HELP, THANK YOU SO MUCH
Consider the below schema of the university database (keys are in bold and underline) Part(pid: string, pname: string, description: string, color: string) Department(did: string, dnamestring, address: string) Supplier(sid string,.sname:string, address:string) Order(did:string. sid string pidstring, time:string, quantityreal, pricereal) The key fields are underlined, and the domain of each field is listed after the field name. Thus pid is the key for Part, did is the key for Department, sid is the key for Supplier, and...
Intro to database systems question:
Question2 (20 points, 5 points each) Consider the following relational schema as part of a university database Prof(sin, pname, o_ce, age, sex, specialty, dept did) Dept(did, dname, budget, num majors, chair sin) Assume the following queries are the most common queries in the workload for this university and they are almost equivalent in frequency and importance Assume that both B+ trees and hashed indexes are supported by the DBMS and that both single and multiple-attribute...
Question2 Consider the following relational schema as part of a university database: Prof(sin, pname, o_ce, age, sex, specialty, dept did) Dept(did, dname, budget, num_majors, chair_sin) Assume the following queries are the most common queries in the workload for this university and they are almost equivalent in frequency and importance: Assume that both B+ trees and hashed indexes are supported by the DBMS and that both single- and multiple-attribute index search keys are permitted. Specify the attributes you recommend indexing on,...
Given the following relational database schema: Student = (SSN, Name, Major) Course = ( CourseNumber , CourseTitle, NumberOfUnits, RoomNumber, DayTime), where DayTime is of the form MW 1:0-2:00. Enrollment = (SSN , CourseNumber, Grade) Express the following queries using SQL statements with minimum number of tables and operations. a. List the SSN and Name of every student who has no grade in at least one course. b. List the name of every student who enrolled in at least two courses....
Consider the relational database schema for a company below. EMPLOYEE/NAME, SSN, BDATE, ADDRESS, SEX, SALARY, SUPERSSN, DNA) TA DEPARTMENT(DNAME, DNUMBER. MESSINS, MGRSTARTDATE) DEPT_LOCATIONS(DNUMBER. DLOCATION PROJECT(PNAME, PNUMBER. PLOCATION, DNLIM) WORKS_ONCESSN.PNG, HOURS) DEPENDENTESSN, DEPENDENT-NAME, SEX, BDATE, RELATIONSHIP) Write SQL statements for the following queries: a) List the names of those employees who work in the "Production" department (6 marks). b) Find the maximum salary, minimum salary, and the average salary among employees who work for the "Production department (6 marks). Count the...
Consider the following relational schema as part of a university database: -age-sex-s-q339281 39 Prof(sin, pname, oce, age, sex, specialty, dept did) Dept(did, dname, budget, num majors, chair sin) ssume the following queries are the most common queries in the workload for this university and they are almost equivalent in frequency and importance ssume that both B+ trees and hashed indexes are supported by the DBMS and that both single- and multiple-attribute index search keys are permitted. Specify the attributes you...