Lab 2

advertisement
DBS201 Lab 2
Introduction to Database
(Updated Winter, 2005)
DBS201 Lab 2
Purpose:
-
Add a schema to the list of schemas to display.
Find a table in a schema.
View the contents of a table.
List the attributes of a table.
Understand relationships between tables.
Last week you saw that you had no database objects in your schema (DC201XXX). Let's have a
look at some database objects from the Premiere database that have been set up for
demonstration purposes.
Part A:
Use iSeries Navigator to sign on to Odin. If you forget how, please review Lab 1!
Expand the Database option. Expand Schemas. What schemas do you see listed there? If you
did not do so last week, add your course schema to the list (if it is not already there). Your course
schema has the same name as your AS/400 userid and will be used to store any files you create
this semester.
Right click Schemas. Click "Select Schemas to Display" to open up this window. (Note that the
“New Schema” option is used to actually create a new schema on the AS/400. Your schema has
already been created for you, we simply wish to display it on the list.) If it is not already there,
enter your schema name, then click Add. You should now see your schema listed in the list on
the right. The Premiere Products database is stored in the Premiere schema so it also needs to
be added to the list that you have. If it is not present, add Premiere to the list as well. Click OK to
close the window. You will not have to perform this step again as iSeries Navigator will
"remember" to keep these schemas on your list (unless you remove them at some point).
Part B:
Expand the Premiere schema by clicking on it. Notice that each database object displayed has a
name, a type and a description. What are fourteen different types of objects listed?
Today we will look at some of the table objects. Firstly, double click on Tables in the right hand
pane, then right click on the Customer table. Then select View Contents. This table is a
representation of the Customer entity.
Use the Customer Table to answer the following questions:
What are the attributes (columns) of this table? (Use the scroll bar to find them all!)
How many customers are there in the Customer table? ____________
What is Tom Daniels' Customer Number? __________________
What is Dan Martin's Balance? __________________
How many customers have the zip code 49441? _________
Which customers live in Grant, Michigan (MI)? ______________________________________
____________________________________________________________________________
How many customers have a credit limit greater than 1000? ______________
What is the Sales_Rep_Number of the sales rep for Mary Nelson? ______________
Which customers have that same sales rep number? __________________________________
DBS201 Lab 2
Introduction to Database
(Updated Winter, 2005)
What other sales rep numbers are listed in the table? ______________________
Close this window.
Part C:
Locate the Salesrep table and open it.
What attributes does the SalesRep table have? _______________________________________
_____________________________________________________________________________
How many rows of data are in the Salesrep table? _________________
What Sales_Rep_Number does Miguel Diaz have? ___________
A Sales Representative is someone who calls on (visits) Customers to encourage them to buy the
goods they are selling. What is the first and last name of the sales representative who calls on
Mary Nelson? ___________________________________ (Hint: see Part B)
Part D:
As you can see, there is a relationship between the Customer table and the SalesRep table.
They are in a sense linked or related through the use of the Sales_Rep_Number. To find the
answer to the previous question, we first obtain the Sales_Rep_Number from the Customer table
then we locate that Sales_Rep_Number on the SalesRep table to obtain the first and last name of
that sales representative.
What is the first and last name of the sales representative who calls on customer Ann Samuels?
___________________________________________
Who calls on Dan Martin? ______________________________________
Open the Orders and OrderLines tables. Examine their contents. Which attribute links these 2
tables? __________________________
Which attribute links the Order table with the Customer table? _________________
What is the name of the Customer for Order Number 12500? _____________________
Examine the Part table. Which attribute links the Part table with the OrderLine table? _________
What is the Part_Description for Part_Number BA74? _____________________
To hand In:
Using the tables you have viewed in this lab, complete the form on the following page and hand it
in to your instructor. Make sure that your name, student number, userid and section are written
on the report.
You may be asked to show your instructor how you retrieved the information for the report.
DBS201 Lab 2
Introduction to Database
(Updated Winter, 2005)
Lab Submission:
Name __________________________
Student No._____________
AS/400 userid______________________ Section ____________
Please complete the following form using the previously viewed tables.
** Note that each order may have multiple orderlines. **
Premiere Order Report For Sales Rep - Miguel Diaz
Order
No.
12491
12498
12504
Customer
Name
Part
No.
Part
Description
Price
Quoted
Number
Ordered
Quantity
On Hand
Download