0% found this document useful (0 votes)
88 views

SQL Machine Problem Series 1

1. The document provides instructions for completing tasks to practice SQL queries. It includes creating databases and tables, inserting sample data, and performing various SELECT, INSERT, UPDATE, and DELETE queries. The tasks involve creating databases and tables for inventory, suppliers, and categories, then practicing queries on the data.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

SQL Machine Problem Series 1

1. The document provides instructions for completing tasks to practice SQL queries. It includes creating databases and tables, inserting sample data, and performing various SELECT, INSERT, UPDATE, and DELETE queries. The tasks involve creating databases and tables for inventory, suppliers, and categories, then practicing queries on the data.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

SQL MACHINE PROBLEMS

Direction:

1. Open XAMPP
2. Kindly accomplish the following tasks listed below under Machine Problem Proper by writing the appropriate MySQL scripts required to complete each tasks using the SQL tab.
3. Your correct answer (MySQL script) to each numbered problem must be pasted on the answer provided on the page below labeled as Answers to SQL Machine Problems.
4. Just before you begin, you must log in your Google account. It must have a profile photo on it

MACHINE PROBLEM PROPER


1. Create a database and name it inventoryDB
2. Create a table and name it products using sql script

Productid Integer, PK, auto increment, not null


Productname Varchar 150, not null
Supplierid Int, not null
Categoryid Int, not null
Units Varchar(100) , not null
Quantity Int, not null
Price Float, not null

3. Insert the following data into the products using sql script

ProductID ProductName SupplierID CategoryID Unit Quantity Price


1 Coke Zero in Can 1 1 10 boxes x 20 cans 100 150.25
2 Pepsi Cola Family Size 2 1 24 - 12 oz bottles 50 250.75
3 Ruffles Sour Cream Potato Chips 3 8 12 - 550 ml bottles 150 200.25
4 Pringles Original Flavor Potato Chips 4 8 48 - 6 oz jars 125 125.75
5 Puno Lychee Buko Sherbet 2 4 36 boxes 85 350
6 Selecta Thick Strawberry Ice Cream 3 4 12 - 8 oz jars 105 255
7 Magnolia Mango Ice Cream 3 4 12 - 1 lb pkgs. 200 275
8 Silver Swan Regular Soy Sauce 3 2 12 - 12 oz jars 300 185.50
9 Datung Puti Cane Vinegar 4 2 18 - 500 g pkgs. 300 45.50
10 Eden Filled Cheese 4 4 12 - 200 ml jars 400 75.75
11 Arla Cream Cheese Spread 5 4 1 kg pkg. 250 145.25
12 Hana Anti-Hairfall Shampoo 5 7 10 - 500 g pkgs. 450 92.50
13 Safeguard Pink Bath Soap 6 7 2 kg box 200 85.75
14 Quaker Rolled Oats 6 5 40 - 100 g pkgs. 100 620.25
15 Minola Vegetable Oil 6 2 24 - 250 ml bottles 125 200.15

4. Create a table and name it suppliers using sql script

supplierid int, PK, not null, auto increment


Suppliername Varchar(50)
Contactname Varchar(50)
Address Varchar(50)
City Varchar(50)
Postalcode Varchar(6)
Country Varchar(20)
phone Varchar(15)

5. Insert the following data to the suppliers table using sql script

Supplier Suppliername Contactname Address City PostalCode Country Phone


ID
1 Lumberjack Food Jose Rizal 49 Gilbert St. Cabanatuan City 3100 UK (171) 555-2222
2 ABC Food Robina
Universal Enterprise
Corporation Andres Noval 65 Del Pilar St. Dagupan City 4502 USA (100) 555-4822
3 Procter and Gamble Philippines Melchora Aquino 125 Barangay Marulas Tarlac City 4810 USA (313) 555-5735
4 Colgate Palmolive Josefa Escoda 2F AJ Building Palayan City 3089 Philippines (03) 3555-5011
5 Talavera Food Rafael Alunan 203 Driza St. Tarlac City 4810 Spain (98) 598 76 54
6 Lea Perrins Gina Lopez 12 Adela Heights Olangapo City 5450 Japan (06) 431-7877
7 Kong Guan Biscuits Gio Robles 45 Cajun Road Talavera City 3058 Australia (03) 444-2343
8 Hapag Vicenticos Andrei Cajucom 29 Telaviv St. Manchester City 4789 UK (161) 555-4448
9 Rebisco Food Services Margie Payawal 47 Pedro Gil St. Sleeping City 5890 Philippines 031-987 65 43
10 Nestle Food Service Carlos Diaz 120 Barangay Perflex Wake-up City 5893 Philippines (11) 555 4640

6. Create a table and name it categories using sql script

Categoryid int, PK, not null, auto increment


Categoryname Varchar(50)
description Varchar(100)

7. Insert the following data to the categories table using sql script

CategoryID CategoryName Description


1 Beverages Soft drinks, coffees, teas, beers, and ales
2 Condiments Sweet and savory sauces, relishes, spreads, and
3 Confections seasonings
Desserts, candies, and sweet breads
4 Dairy Products Cheeses, Milks, Ice Creams
5 Grains/Cereals Breads, crackers, pasta, and cereal
6 Meat/Poultry Prepared meats
7 Hygiene Soaps, Sanitizers, Shampoos
8 Chips All kinds of chips

8. Alter the structure of the products table by adding the column specified below using sql script.
Mobileno varchar(11) not null

THIS PART WILL REQUIRE TO PRACTICE PERFORM QUERIES USING SQL SCRIPT

9. Extract and display all records in the products table


10. Extract and display all records in the categories table in descending orders
11. Extract and display all records in the suppliers table with country value of USA, UK, Spain
12. Extract and display all records in the products table with categoryid 2,3,4,5
13. Extract and display all records in the products table except records with supplierid 3
14. Extract and display categoryid, categoryname in the categories table with categoryname that ends with” ts” in ascending order
15. Extract and display supplierid, contactname, country, phone categoryname in the suppliers table with country that begins with ” U” in descending order
16. Extract and display productname, unit, price in the products table with unit that contains “12”
17. Extract and display all records in the products table with quantity value from 400 to 500.
18. Extract and display all records in the products table with either quantity value of 400 or higher or price of below 200.
19. Insert this record into the categories table using only one INSERT statement with multiple values.

CategoryID CategoryName Description


9 Fixtures Light bulbs, hoses, switches
10 Appliances Refs, TVs, Washing Machines
11 Toys Stuffed Toys, Toy Guns, Dolls

20. Update these records in the suppliers by changing the country to Philippines

Suppli SupplierName ContactName Address City Posta Country Phone


erID lCode
1 Lumberjack Food Jose Rizal 49 Gilbert St. Cabanatuan 3100 UK (171) 555-2222
2 ABC Food Robina
Universal Enterprise
Corporation Andres 65 Del Pilar St. City
Dagupan 4502 USA (100) 555-4822
Bonifacio City

21. Update this categories records categoryname to “Home Fixtures”

CategoryID CategoryName Description


9 Fixtures Light bulbs, hoses, switches

22. Update records in the categories table with country column value of UK to United Kingdom

23. Delete this categories records with categoryname Toys

CategoryID CategoryName Description


9 Fixtures Light bulbs, hoses, switches
WESLEYAN UNIVERSITY-PHILIPPINES
Mabini Extension, Cabanatuan City
www.wesleyan.edu.ph | www.wise.instructure.com | +63444632074
COLLEGE OF ENGINEERING AND COMPUTER TECHNOLOGY

Student Name
Program / Year / Block
Course ITCC6 – Information Management 1
Semester / School Year Second Semester School Year 2020-2021

ANSWERS TO SQL MACHINE PROBLEMS

Q SQL SCRIPT
1

Q SCREENSHOT OF THE OUTPUT


1
Q SQL SCRIPT
2

Q SCREENSHOT OF THE OUTPUT


2
Q SQL SCRIPT
3

Q SCREENSHOT OF THE OUTPUT


3
Q SQL SCRIPT
4

Q SCREENSHOT OF THE OUTPUT


4
Q SQL SCRIPT
5

Q SCREENSHOT OF THE OUTPUT


5
Q SQL SCRIPT
6

Q SCREENSHOT OF THE OUTPUT


6
Q SQL SCRIPT
7

Q SCREENSHOT OF THE OUTPUT


7
Q SQL SCRIPT
8

Q SCREENSHOT OF THE OUTPUT


8
Q SQL SCRIPT
9

Q SCREENSHOT OF THE OUTPUT


9
Q1 SQL SCRIPT
0

Q1 SCREENSHOT OF THE OUTPUT


0
Q1 SQL SCRIPT
1

Q1 SCREENSHOT OF THE OUTPUT


1
Q1 SQL SCRIPT
2

Q1 SCREENSHOT OF THE OUTPUT


2
Q1 SQL SCRIPT
3

Q1 SCREENSHOT OF THE OUTPUT


3
Q1 SQL SCRIPT
4

Q1 SCREENSHOT OF THE OUTPUT


4
Q1 SQL SCRIPT
5

Q1 SCREENSHOT OF THE OUTPUT


5
Q1 SQL SCRIPT
6

Q1 SCREENSHOT OF THE OUTPUT


6
Q1 SQL SCRIPT
7

Q1 SCREENSHOT OF THE OUTPUT


7
Q1 SQL SCRIPT
8

Q1 SCREENSHOT OF THE OUTPUT


8
Q1 SQL SCRIPT
9

Q1 SCREENSHOT OF THE OUTPUT


9
Q2 SQL SCRIPT
0

Q2 SCREENSHOT OF THE OUTPUT


0
Q2 SQL SCRIPT
1

Q2 SCREENSHOT OF THE OUTPUT


1
Q2 SQL SCRIPT
2

Q2 SCREENSHOT OF THE OUTPUT


2
Q2 SQL SCRIPT
3

Q2 SCREENSHOT OF THE OUTPUT


3

You might also like