SlideShare a Scribd company logo
CIS336 Week 5 iLab5

                       PLEASE DOWNLOAD HERE
Lab 5 of 7: Retreiving data from Multiple Tables (28 points)

Submit your assignment to the Dropbox located on the silver tab at the top of this
page. For instructions on how to use the Dropbox, please click here.

(See Syllabus/"Due Dates for Assignments & Exams" for due dates.)

LABOVERVIEW

Scenario/Summary

Lab 5 deals with writing queries using multiple tables as covered in the reading
and lecture material this week. In some cases, you will be given the option to
write a query using either the TRADITIONAL method of joining tables or using the
JOIN key word. In some cases, you will be asked to use a specific approach.
Using the incorrect process when the process is specified will result in points
being taken off for that problem.

The SELECT statement is the primary means of extracting data from database
tables, and allows you to determine exactly which data you want to extract by
means of different comparison operators used in the WHERE clause. This
includes the use of specific "wild card" characters which allow you to search for
character or number patterns within the data. You can also perform mathematical
expressions within the SELECT statement to create derived output. The ORDER
BY clause allows you to sort the output data in either ascending (the default) or
descending order. Lab #5 will explore all of these applications of the SELECT
statement.

General Lab Information and Considerations

This lab will utilize a set of tables found in the script file (LeeBooks.sql) found in
the Doc Sharing area of the website. If you have not yet downloaded this file from
Doc Sharing then do so now. Once you have downloaded the script file, import
and run the script in SQL*Plus.

Each query in the script file you will create must be numbered (use --1 comments
for numbering) and in order. The SQL for the following exercises should be
written using notepad and run in SQL*Plus.

A Clean Script File:
A script file is meant to be like a program. The file can be run every time the code
needs to be executed without having to retype the code again each time. For this
reason, it is important that there are no errors in the code inside the file. You can
go back and forth between Notepad and Oracle when creating your script file to
check your queries and verify if they work or not, but you do not want to create
your final output file until after you have verified that everything in your script is
correct by running it, in its entirety at least once and viewing the output. Once this
has been done, you can create your final output file, with echo on to create the
document you can turn in with your lab. If using a Spool Session, be sure to type
"SPOOL OFF" AT THE SQL> after your Script Stops Spooling!

Lab Do's and Don‟t's

Do Not include the LEEBOOKS.SQL as part of your lab script.

Do use Notepad to write your query script file.

Do Not write your queries in Word.

Do test each query before moving on to the next.

Do Not include extra queries for a problem unless the problem explicitly asks for
more than one query.

Do test your queries before creating your final output file.

Do Not turn in a script file that has queries with errors.

Do number each query using --1 comment notation.

Do Not start your query on the same line as the comment.

Do remember to check your final output and script file for accuracy.

Do Not turn in your lab without first checking your output file to verify that it is
correct.

Things to keep in mind:

If you are not sure of the table names in your user schema, you can use the
following select statement to list them.

SELECT * FROM TAB;

If you want to know the name of the columns in a particular table, you can use the
following command to list them.

DESC
Making a script file containing a series of describe statements for each table and
then spooling the output will give you a listing of all the tables with column names.

Be sure to review and verify your final output when you are finished. Do Not
assume anything.

Write queries for each of the stated problems in the steps below that will return a
result set of data to satisfy the requirements. When finished, your script file
should have a total of 13 queries and your resulting output file should show both
the query and result set for each.

Deliverables

Submit for grading:

Your script file with the 13 queries in it. Be sure your name, course number, and
lab number are in a comment area at the top of your file. Submitting ONLY your
spooled output will result in a 10-point deduction.

An output file created using SET ECHO ON showing both the SQL code and the
results.

Both documents must be zipped into a single file before submitting to the
iLabDropbox for Week 5.

LABSTEPS

STEP 1:

Using the BOOKS and PUBLISHER tables, create a query using the traditional
join method that will return a list containing the book title, publisher contact
person, and publisher phone number for all publishers whose publisher name
starts with an „R‟.

STEP 2:

Using the DUAL table, create a query that will return the day of the week, hour,
minutes, and seconds of the current date setting on a computer. The day should
be in all upper case.

STEP 3:

Using the BOOK_CUSTOMER and BOOK_ORDER tables, create a query using
the NATURAL JOIN method that will return a list containing the customer first
name and last name and the order number for all orders that have been shipped.
Give the customer name column an alias of "Customer Name" and order the
output by the customer number in the BOOK_ORDER table in ascending order.
STEP 4:

Using the BOOK_ORDER table, create a query that will return the order number,
order date, shipping address, city, state, and zip code for all orders going to
Atlanta or Austin. Format the order date to display as Month DD, YYYY and give
the column an alias of "Date Ordered". Be sure the month begins with a capital
letter.

STEP 5:

Using the BOOK_ORDER table, create a query using the correct function to
return the order number, the date ordered, the date shipped, and a column
representing the number of months between the two dates for all columns where
a date shipped exists. Format the number returned from the function to display
only two decimals, and give the column an alias of "Months Between".

NOTE: Be sure that all of the numbers in the fourth column are positive numbers.

STEP 6:

Using the correct tables in your schema, create a query using either join
operation that will list the title of each book and author name(s). Give the title
column an alias of "Book Title". Sort the results by title and then by author last
name.

STEP 7:

Using the BOOKS table, create a query that will return the book title, cost, and
retail price for all books with a title starting with the letter „H‟. Use the correct
conversion function to format the cost and retail columns to show dollars and
cents with a dollar sign (e.g., a price of $25 would display $25.00 in the result
set).

STEP 8:

Using the BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query
using an OUTER JOIN operation that will list the book title, order date, and order
number for all books in the BOOKS table. Order your output in descending order
by ORDER_ITEMS.BOOKID. There are three books that have never been
ordered which should show up at the top of your listing.

STEP 9:

Using the correct tables, create a query using the traditional join operation that
will list the customer first and last name, book title, and order date (formatted as
MM/DD/YYYY with an alias of “Order Date”) for all the customers who have
purchased books published by 'PRINTING IS US'.
STEP 10:

Using the BOOKS and ORDER_ITEMS table, write a query using the correct
Relational Set Operator that will show all of the Book IDs in the BOOKS table that
have not been ordered.

STEP 11:

Using the BOOK_CUSTOMER, BOOK_ORDER, ORDER_ITEMS, and BOOKS
tables, create a query using traditional join conditions based on comparisons
between primary and foreign keys that will list the customer number, first and last
name, and book title. Limit your listing to only those books in the „FITNESS‟
category.

STEP 12:

Using the BOOKS, ORDER_ITEMS, and BOOK_ORDER tables, create a query
that will list the title, retail, quantity, and order date for all books ordered after April
30, 2009.

STEP 13:

Using the correct tables, create a query using either join operation you wish that
will list the order id, order date, quantity ordered, and retail price for every book
that has been ordered. Format the date as MM/DD/YYYY with an alias of “Order
Date” and format the retail price column using the correct function to show dollars
and cents with a dollar sign ( $ ) and a column alias of “Retail”.

This is the end of lab #5

More Related Content

DOCX
Cis 336 ilab 5 of 7
comp274
 
DOCX
Cis 336 cis336 week 5 i lab 5 devry university
miteamosku
 
DOC
Cis336 week 5 i lab 5
7Fase1
 
DOCX
CIS/336 ilab 5 of 7
ashhadiqbal
 
DOC
Cis336 week 4 i lab 4
7Fase1
 
DOC
Cis336 week 7 i lab 7
CIS339
 
DOCX
How to create lists in millennium july 2011
nybglibrary
 
PPT
Generate Excel documents with Rational Publishing Engine 1.1.2 and Reporting ...
GEBS Reporting
 
Cis 336 ilab 5 of 7
comp274
 
Cis 336 cis336 week 5 i lab 5 devry university
miteamosku
 
Cis336 week 5 i lab 5
7Fase1
 
CIS/336 ilab 5 of 7
ashhadiqbal
 
Cis336 week 4 i lab 4
7Fase1
 
Cis336 week 7 i lab 7
CIS339
 
How to create lists in millennium july 2011
nybglibrary
 
Generate Excel documents with Rational Publishing Engine 1.1.2 and Reporting ...
GEBS Reporting
 

What's hot (10)

PPT
Microsoft excel
Sonia Agustin
 
PPTX
RefWorks, Intro
Traciwm
 
PPTX
RefWorks How to version 1
Traciwm
 
PDF
Altering Drop-Down Menus for Admissions IT Service Request Form
Edwin Jackson
 
PDF
XLS PE How To Tutorials Tips & Tricks
guest92a5de
 
PPTX
Sweeping out the cobwebs: Content auditing for large websites
Nexer Digital
 
PDF
Schema plus
Michał Łomnicki
 
PPTX
Phpmyadmin administer mysql
Mohd yasin Karim
 
PPT
Oracle Forms Tutorial (www.aboutoracleapps.com)
magupta26
 
DOCX
CIS 336 (DEVRY) Entire Course NEW
shyamuopuop
 
Microsoft excel
Sonia Agustin
 
RefWorks, Intro
Traciwm
 
RefWorks How to version 1
Traciwm
 
Altering Drop-Down Menus for Admissions IT Service Request Form
Edwin Jackson
 
XLS PE How To Tutorials Tips & Tricks
guest92a5de
 
Sweeping out the cobwebs: Content auditing for large websites
Nexer Digital
 
Schema plus
Michał Łomnicki
 
Phpmyadmin administer mysql
Mohd yasin Karim
 
Oracle Forms Tutorial (www.aboutoracleapps.com)
magupta26
 
CIS 336 (DEVRY) Entire Course NEW
shyamuopuop
 
Ad

Viewers also liked (18)

PPT
Cibercultura
DaNii HurTado
 
DOC
Avaluació material interactiu Matías Morales
Matías Morales Fajardo
 
PPTX
كيف تربح البنوك الإسلامية دون أن تتقاضى فائدة
ashwag3sh
 
PDF
Intervento Stampa 3D - Francesco Bombardi, architetto, fondatore FabLab Reggi...
redazione_livinginterior
 
PDF
Newsletter dated 23rd May,2015
Rajiv Bajaj
 
PPTX
GFARD Estudio Regional para América Latina y El Caribe
CIAT
 
PDF
Scio
Xavi Gasset
 
PDF
Luis lozada actividad.1_2mapac
Luis Alfredo Lozada Perez
 
PPTX
Pak asia company profile
pakasia
 
PPTX
Internet of Things
Mphasis
 
DOC
Descriptores
karla
 
PPTX
PRESENTACION
Riicardoo Toroo
 
PDF
Status report 9
Clifford Stone
 
PDF
Fazenda santa nice apresentação site - nova
Andreoni Camargo
 
DOC
Nilesh_Bhandari_CV Dec 2014 V final 1 0 v 1 for SM Baseline
Nilesh Bhandari
 
PDF
Ciudades para un pequeño planeta cap 2.pdf
Stalin Solís Pazmiño
 
PPTX
Project FENIX
APNIC
 
Cibercultura
DaNii HurTado
 
Avaluació material interactiu Matías Morales
Matías Morales Fajardo
 
كيف تربح البنوك الإسلامية دون أن تتقاضى فائدة
ashwag3sh
 
Intervento Stampa 3D - Francesco Bombardi, architetto, fondatore FabLab Reggi...
redazione_livinginterior
 
Newsletter dated 23rd May,2015
Rajiv Bajaj
 
GFARD Estudio Regional para América Latina y El Caribe
CIAT
 
Luis lozada actividad.1_2mapac
Luis Alfredo Lozada Perez
 
Pak asia company profile
pakasia
 
Internet of Things
Mphasis
 
Descriptores
karla
 
PRESENTACION
Riicardoo Toroo
 
Status report 9
Clifford Stone
 
Fazenda santa nice apresentação site - nova
Andreoni Camargo
 
Nilesh_Bhandari_CV Dec 2014 V final 1 0 v 1 for SM Baseline
Nilesh Bhandari
 
Ciudades para un pequeño planeta cap 2.pdf
Stalin Solís Pazmiño
 
Project FENIX
APNIC
 
Ad

Similar to Cis336 week 5 i lab5 (20)

DOC
Cis336 week 5 i lab 5
jskdhklsduopuo0980
 
DOC
Cis336 week 5 i lab 5
CIS339
 
DOC
Cis336 week 5 i lab 5
jackiechaner
 
DOC
Cis336 week 4 i lab 4
CIS339
 
DOC
Cis336 week 4 i lab 4
jskdhklsduopuo0980
 
DOC
Cis336 week 4 i lab 4
jackiechaner
 
DOCX
ECET 450 Laboratory 2Lab 2 involves two parts.Part A involv.docx
jenkinsmandie
 
DOCX
ECET 450 Laboratory 2Part BPurposeThis laborato.docx
jack60216
 
PPTX
Advanced Spreadsheet Skills-1.pptx
CliffordBorromeo
 
DOCX
BUSI 301 Book Review RubricScoreCommentsResearch 25.docx
humphrieskalyn
 
PPTX
9 - Advanced Functions in MS Excel.pptx
SheryldeVilla2
 
PDF
Illustrated Microsoft Office 365 and Office 2016 Fundamentals 1st Edition Hun...
wardahbleakk0
 
PDF
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
nimoxmagels4
 
PDF
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
snonowevers
 
PDF
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
jbumbmeeg0132
 
DOCX
CS 111 - Homework 5 p. 1CS 111 - Homework 5Deadline1.docx
annettsparrow
 
DOCX
CS1100 Access Lab 1 Creating and Querying Database.docx
faithxdunce63732
 
PDF
Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition Anth...
rostjareon
 
DOCX
Page 3 of 11Delete this text and type your name here This .docx
alfred4lewis58146
 
PDF
Illustrated Microsoft Office 365 and Office 2016 Fundamentals 1st Edition Hun...
schaadkirer
 
Cis336 week 5 i lab 5
jskdhklsduopuo0980
 
Cis336 week 5 i lab 5
CIS339
 
Cis336 week 5 i lab 5
jackiechaner
 
Cis336 week 4 i lab 4
CIS339
 
Cis336 week 4 i lab 4
jskdhklsduopuo0980
 
Cis336 week 4 i lab 4
jackiechaner
 
ECET 450 Laboratory 2Lab 2 involves two parts.Part A involv.docx
jenkinsmandie
 
ECET 450 Laboratory 2Part BPurposeThis laborato.docx
jack60216
 
Advanced Spreadsheet Skills-1.pptx
CliffordBorromeo
 
BUSI 301 Book Review RubricScoreCommentsResearch 25.docx
humphrieskalyn
 
9 - Advanced Functions in MS Excel.pptx
SheryldeVilla2
 
Illustrated Microsoft Office 365 and Office 2016 Fundamentals 1st Edition Hun...
wardahbleakk0
 
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
nimoxmagels4
 
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
snonowevers
 
Practical SQL A Beginner s Guide to Storytelling with Data 2nd Edition Anthon...
jbumbmeeg0132
 
CS 111 - Homework 5 p. 1CS 111 - Homework 5Deadline1.docx
annettsparrow
 
CS1100 Access Lab 1 Creating and Querying Database.docx
faithxdunce63732
 
Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition Anth...
rostjareon
 
Page 3 of 11Delete this text and type your name here This .docx
alfred4lewis58146
 
Illustrated Microsoft Office 365 and Office 2016 Fundamentals 1st Edition Hun...
schaadkirer
 

Cis336 week 5 i lab5

  • 1. CIS336 Week 5 iLab5 PLEASE DOWNLOAD HERE Lab 5 of 7: Retreiving data from Multiple Tables (28 points) Submit your assignment to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, please click here. (See Syllabus/"Due Dates for Assignments & Exams" for due dates.) LABOVERVIEW Scenario/Summary Lab 5 deals with writing queries using multiple tables as covered in the reading and lecture material this week. In some cases, you will be given the option to write a query using either the TRADITIONAL method of joining tables or using the JOIN key word. In some cases, you will be asked to use a specific approach. Using the incorrect process when the process is specified will result in points being taken off for that problem. The SELECT statement is the primary means of extracting data from database tables, and allows you to determine exactly which data you want to extract by means of different comparison operators used in the WHERE clause. This includes the use of specific "wild card" characters which allow you to search for character or number patterns within the data. You can also perform mathematical expressions within the SELECT statement to create derived output. The ORDER BY clause allows you to sort the output data in either ascending (the default) or descending order. Lab #5 will explore all of these applications of the SELECT statement. General Lab Information and Considerations This lab will utilize a set of tables found in the script file (LeeBooks.sql) found in the Doc Sharing area of the website. If you have not yet downloaded this file from Doc Sharing then do so now. Once you have downloaded the script file, import and run the script in SQL*Plus. Each query in the script file you will create must be numbered (use --1 comments for numbering) and in order. The SQL for the following exercises should be written using notepad and run in SQL*Plus. A Clean Script File:
  • 2. A script file is meant to be like a program. The file can be run every time the code needs to be executed without having to retype the code again each time. For this reason, it is important that there are no errors in the code inside the file. You can go back and forth between Notepad and Oracle when creating your script file to check your queries and verify if they work or not, but you do not want to create your final output file until after you have verified that everything in your script is correct by running it, in its entirety at least once and viewing the output. Once this has been done, you can create your final output file, with echo on to create the document you can turn in with your lab. If using a Spool Session, be sure to type "SPOOL OFF" AT THE SQL> after your Script Stops Spooling! Lab Do's and Don‟t's Do Not include the LEEBOOKS.SQL as part of your lab script. Do use Notepad to write your query script file. Do Not write your queries in Word. Do test each query before moving on to the next. Do Not include extra queries for a problem unless the problem explicitly asks for more than one query. Do test your queries before creating your final output file. Do Not turn in a script file that has queries with errors. Do number each query using --1 comment notation. Do Not start your query on the same line as the comment. Do remember to check your final output and script file for accuracy. Do Not turn in your lab without first checking your output file to verify that it is correct. Things to keep in mind: If you are not sure of the table names in your user schema, you can use the following select statement to list them. SELECT * FROM TAB; If you want to know the name of the columns in a particular table, you can use the following command to list them. DESC
  • 3. Making a script file containing a series of describe statements for each table and then spooling the output will give you a listing of all the tables with column names. Be sure to review and verify your final output when you are finished. Do Not assume anything. Write queries for each of the stated problems in the steps below that will return a result set of data to satisfy the requirements. When finished, your script file should have a total of 13 queries and your resulting output file should show both the query and result set for each. Deliverables Submit for grading: Your script file with the 13 queries in it. Be sure your name, course number, and lab number are in a comment area at the top of your file. Submitting ONLY your spooled output will result in a 10-point deduction. An output file created using SET ECHO ON showing both the SQL code and the results. Both documents must be zipped into a single file before submitting to the iLabDropbox for Week 5. LABSTEPS STEP 1: Using the BOOKS and PUBLISHER tables, create a query using the traditional join method that will return a list containing the book title, publisher contact person, and publisher phone number for all publishers whose publisher name starts with an „R‟. STEP 2: Using the DUAL table, create a query that will return the day of the week, hour, minutes, and seconds of the current date setting on a computer. The day should be in all upper case. STEP 3: Using the BOOK_CUSTOMER and BOOK_ORDER tables, create a query using the NATURAL JOIN method that will return a list containing the customer first name and last name and the order number for all orders that have been shipped. Give the customer name column an alias of "Customer Name" and order the output by the customer number in the BOOK_ORDER table in ascending order.
  • 4. STEP 4: Using the BOOK_ORDER table, create a query that will return the order number, order date, shipping address, city, state, and zip code for all orders going to Atlanta or Austin. Format the order date to display as Month DD, YYYY and give the column an alias of "Date Ordered". Be sure the month begins with a capital letter. STEP 5: Using the BOOK_ORDER table, create a query using the correct function to return the order number, the date ordered, the date shipped, and a column representing the number of months between the two dates for all columns where a date shipped exists. Format the number returned from the function to display only two decimals, and give the column an alias of "Months Between". NOTE: Be sure that all of the numbers in the fourth column are positive numbers. STEP 6: Using the correct tables in your schema, create a query using either join operation that will list the title of each book and author name(s). Give the title column an alias of "Book Title". Sort the results by title and then by author last name. STEP 7: Using the BOOKS table, create a query that will return the book title, cost, and retail price for all books with a title starting with the letter „H‟. Use the correct conversion function to format the cost and retail columns to show dollars and cents with a dollar sign (e.g., a price of $25 would display $25.00 in the result set). STEP 8: Using the BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query using an OUTER JOIN operation that will list the book title, order date, and order number for all books in the BOOKS table. Order your output in descending order by ORDER_ITEMS.BOOKID. There are three books that have never been ordered which should show up at the top of your listing. STEP 9: Using the correct tables, create a query using the traditional join operation that will list the customer first and last name, book title, and order date (formatted as MM/DD/YYYY with an alias of “Order Date”) for all the customers who have purchased books published by 'PRINTING IS US'.
  • 5. STEP 10: Using the BOOKS and ORDER_ITEMS table, write a query using the correct Relational Set Operator that will show all of the Book IDs in the BOOKS table that have not been ordered. STEP 11: Using the BOOK_CUSTOMER, BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query using traditional join conditions based on comparisons between primary and foreign keys that will list the customer number, first and last name, and book title. Limit your listing to only those books in the „FITNESS‟ category. STEP 12: Using the BOOKS, ORDER_ITEMS, and BOOK_ORDER tables, create a query that will list the title, retail, quantity, and order date for all books ordered after April 30, 2009. STEP 13: Using the correct tables, create a query using either join operation you wish that will list the order id, order date, quantity ordered, and retail price for every book that has been ordered. Format the date as MM/DD/YYYY with an alias of “Order Date” and format the retail price column using the correct function to show dollars and cents with a dollar sign ( $ ) and a column alias of “Retail”. This is the end of lab #5