Answered step by step
Verified Expert Solution
Question
1 Approved Answer
computer science Introduction to databases SP22 Assignment ! Description of the schema The following database is used by a building materials company to edit invoices
computer science
Introduction to databases SP22 Assignment ! Description of the schema The following database is used by a building materials company to edit invoices for its customers and to manage its inventory The schema of this database contains the following tables: The customer table is used to record the properties of the company's customers, name, address, etc. The product table is used to record the properties concerming the building materials available for sale: their description, the unit price, the quantity in stock The order table is used to record the properties concerning an order its number, the date of the order and the customer identifier The ordered Product table is used to record the lines of orders along with the products the order identifier (order NO), the product identifier (productNO) and the quantity ordered. Customer (customsTNO. customer Name, address, city, category, custBalance) Product (productNO, label, price, QStock) customer Order (orderNO, ordetDate, customerNO) ordered Product order NO. predstNO.orderQuantity) Note: Primary keys are underlined and foreign key are marked with Use SQL Developer to answer the questions given below. 1) Open a new SQL worksheet then write the SQL commands to create the tables' structures of the above database (enforce primary key and foreign key constraints). Save this script Schema_creation.sql 12.53 Customer Product customer Order customerNO char(8) productNO char(10) Order NO char(8) customer Name Varchar (20) Tabel Varchar (30) order Date Date address Varchar(40) price Decimal9.2) customer NO char(8) city Varchar(20) QStock Number(11) Category Char(2) ordered duct custBalance Decimal(9,2) Jorder NO char(8) productNO char(10) order Quantity Number(11) 2) Open a new SQL worksheet then write the INSERT commands necessary to place the following data in the tables that were created in the previous question. Save this script as table_population.sgl-(2.51 Introduction to databases SP22 Customer customer NO customer Name address city Category custBalance B062 Ahmed 72 street Freedom Salalah B2 -100 B112 Salim Street Sultan Qaboos Muscat CI 1250 B332 Alia Building Hana Street Alhisn Ibri B2 0.00 BS12 Taoufiq Building Alaamra Rustag 1 -500 C003 Islam House N 5 Street Asahafa Salalah BI -1000 C123 Murad Building Asalalm Main Street Ibri C1 -2000 C400 Jamilah Street of garden House n 5 Muscat B2 350 Product customer Order productNO label Price QStock order Norder Date customerNO CS262 Chev.fir 200x6x2 75 45 30178 21-DEC-2017 C400 CS264 Chev.fir 200x6x4 120 2690 30179 22-DEC-2017 BS12 CS464 Chev.fir 400x6x4 220 450 30182 23-DEC-2017 C400 PA45 Steel point 45 (1K) 105 580 30184 23-DEC-2017 B062 PA60 Steel point 60 (1K) 95 134 30185 02-JAN-2018 B332 PH222 PL.Hetre 200x20x2 230 782 30186 02-JAN-2018 C400 PS222 PL.fit 200x20x2 185 1220 30188 03-JAN-2018 C003 ordered Product orderNO productNO order Quantity 30178 CS464 25 30179 CS262 60 30179 PA60 20 30182 PA60 30 30184 CS464 120 30184 PA45 20 30185 CS464 260 30185 PA60 15 30186 PS222 600 30186 PA45 3 30188 PA60 180 30188 PH222 92 Introduction to databases SP22 3) Open a new SQL worksheet then write in SQL the queries, which answer the questions below. Save the script as queries.sql (write the number of question as comment before cach query) a) Display in alphabetical order the list of cities in which there is at least one customer.[0,5] b) Display the number, name and city of customers who belong to category Cl and who are not living in Muscat. [0.5) c) List the characteristics of products made of steel [0.5] d) Display the details of products having a price under 200 and a stock more than 150,[0.5] e) List the number, name and balance of customers who are from Salalah or Thri and whose balance is positive,[0.51 1) List the number of cities in which there are customers of category C1 [0.5] ) Display the number of customers who have placed at least one order. [05] h) Calculate, for each city, the number of distinct categories. (0.75) 1) Assign zero to the balance of customers of category CI and whose balance is negative. [0.75] 1) Change to 10 units the ordered quantity of the product number PA60 in the order number 30185.[0.75] k) Calculate the total amount in the stock of products made of fir [0.75] 1) Display the details (order NO, order Date ) of the most recent order.[1] m) Display the details of orders (order NO, orderDate, customerNO) which doesn't include the products having the code PA60. [1] n) Display numbers and names of customers who are from Muscat and have not placed orders. [1] o) Display numbers of products (productNO) which are made of fir and are placed in orders. p) Find for each product the list of cities in which this product is ordered in more than 500 units [15] q) List, for each customer category, the number of products that were ordered on 23-12- 2008.[1.5) 4) Open a new SQL worksheet then write a SQL statement to create a view named orderPerClient which will contain the number of orders placed by each customer. Save this script as view_creation.sql. [15] 5) Create a new folder named assignment1_your ID. Put in this folder all the scripts created in the above questions. Compress the folder then submit it via Blackboard on or before 17-March- 2022 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started