Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
bartleby
Concept explainers
Question
Transcribed Image Text:Part II (50 points, each problem is worth 5 points)
Write SQL queries for the following database:
id
Customers
name
email
id
Categories
name
Ho
Ho
8 Orders
id
customer_id
B
id
Products
category_id
name
price
но
HO
Order_Product
id
order_id
product_id
quantity
1. Display all customers whose email is null or ends with 'fiu.edu' or 'gmail.com'
2. Display the number of orders placed by a customer whose name is ‘Jason Bourne'
(assume there is only one customer with this name).
3. Insert a new product (category_id = 1, name = 'apple', price = 3.00) into the product
table. Assume Products.id has a default value.
4. Create the Order_Product table as follows: id is the primary key and its data type is
serial, quantity is an integer which doesn't allow null, order_id and product_id are
foreign keys and will be set to null on delete.
5. Display the average price of all the products. For example, there are only three
products in the database with a price of 7, 8 and 9. Then the average price would be 8.
6. Display all categories with the number of products in them. Note that categories with
no products in them also need to be listed, with the number equals to 0. An example
output:
category_name
Books
Phones
Clothes
total_products
60
7
15
0
7. Display the total sales amount (the sum of all orders' total amount). For example,
there're only two orders in the database. One order bought 2 iPhones with a unit price of
10, the other order bought 5 iPads with a unit price of 8. Then, the total sales amount
would be 2*10 + 5*8 = 60. An example output:
sale_amount
Expert Solution
Check Markarrow_forward
Step 1
Since there are multiple parts to a single question, the first three subparts are answered for you. If you want the answers to the rest of the questions, please post those questions separately.
bartleby
Step by stepSolved in 4 steps
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write SQL statements to do the following on the database schema shown below in the picture. a) Insert a new record in the course table with the following data values course number = 'COSC4390' course name = 'Knowledge Engineering' course credit hours= ‘3’ department = ’COSC'>. b) Change the class of student 'Ahmed' to 4. c) Delete the record of the student whose name is 'Ahmed' and his number is 22.arrow_forwardq4- Choose all that applyarrow_forwardSQL Question~ Write SQL expression to list flight_no and airline_code of all the bookings for customers with first name Sam and city Chicagoarrow_forward
- Based on SQL informationarrow_forwardCreate an anonymous block in PL/SQL to list all the countries from Country table where Currency contain keyword ‘Dollar’. Perform following steps: Create user define type with name of the country, currency.Type should contain datatype for name and currency using %type only.Display should include Name of the country, currency code using user defined type. Filter for the data : All the countries from Country table where Currency contain keyword ‘Dollar’.arrow_forwardUse your ERD to define the table structures in the database using SQL DDL commands to build your schema.arrow_forward
- Express the following SQL code in Relational Algebra form.SELECT *FROM COURSEWHERE (COURSE.COLLEGE <> ’Business’OR COURSE.COLLEGE <> ’Engineering’)AND COURSE.CREDIT = ’U’;arrow_forwardwrite SQL queries to create procedures for a database called Saleco. The database contains the following tables: customer, invoice, line, product, and vendor. A procedure called get_customer_invoices that takes a customer ID as input and returns a list of all invoices for that customer, along with the total amount due for each invoice. A procedure called get_vendor_products that takes a vendor ID as input and returns a list of all products sold by that vendor, along with the number of units sold and the total revenue generated for each product. A procedure called get_invoice_details that takes an invoice ID as input and returns a list of all products purchased on that invoice, along with the quantity purchased, the unit price, and the total price for each product.arrow_forwardBased on SQL query knowledgearrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education