Lab 5 will introduce the concept of multi-table JOINS in order to work with data in two or more related tables simultaneously. This lab may be completed using either DeVry’s Omnymbus EDUPE-APP lab environment, or a local copy of the MySQL database running on your own computer using the OM database tables. The lab will utilize a set of tables that are represented by the ERD (OM_ERD.docx) and are created and populated by the script file (create_OM_db.sql). Follow the instructions in the file CreateOMTables.docx to create your database, tables, and data.
A few IMPORTANT things to note if using EDUPE MySQL: **There can be NO SPACES in alias names given to a column. For example: Select unit_price as “Retail Price “ from items; –this does NOT work in EDUPE MySQL. Any of the following WILL WORK:
1234
Select unit_priceas“RetailPrice” from items;Select unit_priceas“Retail_Price” from items;Select unit_priceasRetail_Price from items;Select unit_priceasRetailPrice from items;
**Any calculated fields MUST be given an alias (and note above NO SPACES in alias). For example:
123
select unit_price * 2 from items; –this does NOT work in EDUPE MySQLThis will work:select unit_price * 2asNewPrice from items;
Deliverables Lab Report (Answer Sheet) containing both the student-created SQL command(s) for each exercise, and the output showing the results obtained. Be sure your name is on the file.
LAB STEPS: Complete each of the exercises below:
Use the JOIN ON syntax to write a query to display the order id, order date, customer name formatted as a single field (i.e. “Tom Jones”) with a heading of Customer, and customer_city for customers residing in the state of OHIO. Sort the output to display the newest orders first.
Use the JOIN USING syntax to display the order_id, order date, and shipdate for orders to Karina Lacy that have shipped.
Use the implicit join syntax (the WHERE clause) to display the last name, city, order date and ship date for all orders shipped in 2012.
Use any join syntax EXCEPT NATURAL JOIN to list the customer_first_name and customer_last_name concatenated with an intervening space as Customer, customer city and state formatted as a single column in the format of “city, ST” with a heading of Location, order_id and order date for orders that have not shipped.
List the customer name, order date, zipcode for any customer(s) placing an order for the item titled ‘Etcetera”.
Write a query to list the title and artist of ONLY the items that have been ordered. Only list each title once.
Write a query to list the title and price of all items that have been ordered by customer Millerton.
Write a query to list the last name and order id of customers that ordered any items by the artist Burt Ruggles?
Write a query to display a list of titles along with the artist name., sorted by artist name.
Write a query to display an invoice for order 693 including the title, quanty, price, and a calculated column to display the line item subtotal (quantity times price) with a heading of Subtotal.
Display the order id, last name, title , and quantity for any items where customers have ordered 2 or more of a particular item in an order.
The employees table contains a list of employees of a company. An employee may be managed by another employee. To denote an employee’s manager, the employee_id of the manager is entered into the manager_id field of the employee reporting to that manager. In order to produce a list of which managers supervise which employees, the table may be joined to itself using these two attributes (employee_id, manager_id). This is known as a SELF-JOIN. Use a SELF-JOIN on the employees table to produce a result containing two columns: the concatenated last_name and first_name of the manager, and the concatenated last_name and first_name of the employee. Label the first-column supervisor, and the second-column employee. Order the output by the supervisor’s last_name and first_name.
Write a query to display the order id, order date, ship date, and customer last name for all SHIPPED orders placed on the internet (no employee id). Show the most recently shipped orders first.
Write a query that displays the order id, order date, and employee name as a single field labeled Employee for each order that an employee assisted with.
Write a query that displays the order id, order date, customer name as a single field labeled Customer for all orders for the sales rep Thomas Hardy, sorted by customer last name.
CIS336 Lab 1 Normal Forms and Entity Relationship Diagrams,
CIS 336 Lab 2 The Expanded Entity Relationship Diagram,
CIS336 Lab 3 Building the Physical,
CIS336 Lab 4 Introduction to Select Insert Update and Delete Statements,
In this CIS336 LAB 1 exercise, you will analyze a de-normalized data set presented in the form of a spreadsheet. You will next construct a series of dependency diagrams, transforming the evolving data model from First Normal Form (1NF), to Second Normal Form (2NF), and finally to Third Normal Form (3NF). When the model has reached 3NF, you will construct the Entity Relationship Diagram (ERD) depicting the logical design of the database. Your ERD will use Crow’s Foot notation to denote the relationships between tables.
The CIS336 LAB 3 lab for this week addresses taking a logical database design (data model) and transforming it into a
physical model (tables, constraints, and relationships). As part of the lab, you will need to download the zip file titled CIS336Lab3Files from Doc Sharing. This zip file contains the ERD, Data Dictionary, and test data for the tables you create as you complete this exercise.