Question

Having trouble writing two mysql queries for this schema The low level conceptual model of the...

Having trouble writing two mysql queries for this schema

The low level conceptual model of the restaurant database is provided below:

DATABASE:

RESTAURANT (res_name[pk], City, Phone, Owner_SSN[pk,fk])

FOOD (food_name[pk], Type, Country, Proof)

CUSTOMER (SSN[pk], Name, Birth_year, Fav_food[fk], Gender)

LIKES (SSN[pk,fk], food[pk,fk]) SERVES (res[fk], foods[fk])

OWNER (SSN[pk], Name, City, Address, Phone)

QUERIES

14) Find the total number of foods that are liked by customers. Note that if a food is repeatedly liked by several people, it is just counted as once.

15) List the number of old customers from each gender, only if they are more than 1. For instance, if the number of old male customers is 1, it should not be shown in the results. A customer is considered old if he/she is at least 65 years old.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Select COUNT(DISTINCT l.food) FROM FOOD f Inner join LIKES l ON f.food_name=l.food;

Above mentioned query has two level of function used to get results.

Select Gender,count(SSN) AS Count customers from CUSTOMER WHERE (YEAR(CURDATE()) - birth_year) >=65 GROUP BY GENDER HAVING Count(SSN)>1;

Add a comment
Know the answer?
Add Answer to:
Having trouble writing two mysql queries for this schema The low level conceptual model of the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 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:...

  • Consider a database with the following schema. Return SQL code for the following queries.

    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...

  • Given the following relational schema, write queries in SQL to answer the English questions. The Access...

    Given the following relational schema, write queries in SQL to answer the English questions. The Access Database for the schema is available, as is a DDL file. It is also available on the MySQL server. You must only submit the SQL for your answers. You can get your answers without using a DBMS or by using Access or MySQL. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid:...

  • Hello, I need help answering all 8 of these questions for my BIS 422 class. I...

    Hello, I need help answering all 8 of these questions for my BIS 422 class. I need the appropriate MySQL script to use for these questions Provide the SQL for the following data requests. Your SQL should be written as a single script that can be pasted into MySQL and run without edits. Make sure you use the proper notation for your comments (see the practice solution for an example of the format). There will be a 5% deduction for...

  • In using a database created from this model, which of the following SQL queries would give...

    In using a database created from this model, which of the following SQL queries would give us a list of customers who have daily deposit transactions (deposit is a transaction type) totaling $10,000 or more across all of their accounts (i.e., this is a total across all accounts of a customer, not per account). Include in this list the Customer ID and name, and the dates and their respective daily total. SELECT c.cust_id, c.cust_name, DATE(t.tran_date), SUM(t.tran_amount) AS daily_total FROM Customers...

  • I need help with this please, I'm very confused. Given the following relational model database schema:...

    I need help with this please, I'm very confused. Given the following relational model database schema: GUEST (email, address, phone_no, name) (phone_no) is a candidate key. Email and address are long strings, phone_no and name are also strings. TYPE (code, description) The type code is a numeric code and the description a length varying string. AMENITY (code, description) The amenity code is a numeric code and the description a length varying string. CITY (city_id, name, state, country) The city identification...

  • SQL: The schema name should be mxxws, where mxx is your MySQL user name. To refresh...

    SQL: The schema name should be mxxws, where mxx is your MySQL user name. To refresh your memory – here is the schema for that database: Create the rest of the contact management database by writing the statements that do each of the following items below. For each one: (1) execute them on your copy of the database, and (2) write the statements in the space: Statement to create the Contact table (one statement) Statement to create the Employee table...

  • The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind...

    The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind Traders, which imports and exports specialty foods from around the world. Here is the schema of the database: Products (ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued); Suppliers (SupplierID, CompanyName, ContactName , ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage); Categories (CategoryID, CategoryName, Description, Picture); Orders (OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia,  Freight, ShipName,ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry); Order_details (ID, OrderID,...

  • SQL Queries – in this assignment you will be asked to create several SQL queries relating...

    SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...

  • The assignment requires reading and understanding the data model used by Cassandra and representing a given ER model with Cassandra “tables”. The decision of which tables to define is driven by the qu...

    The assignment requires reading and understanding the data model used by Cassandra and representing a given ER model with Cassandra “tables”. The decision of which tables to define is driven by the queries that need to be answered. A software company is interested in developing a Video Sharing application. They have designed a conceptual model of the data they need to handle in order to offer users these main functions: 1. The creation of channels where they can upload videos....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT