CST-133 DataBase Labs Access DataBase Labs -- Muggwump Fish Farm Click your left mouse button to...
-
Upload
suzan-clark -
Category
Documents
-
view
215 -
download
0
Transcript of CST-133 DataBase Labs Access DataBase Labs -- Muggwump Fish Farm Click your left mouse button to...
CS
T-1
33 D
ataB
ase
Lab
s
Access DataBase Labs-- Muggwump Fish Farm
Click your left mouse button to proceed . . .
© Delta College CST Faculty
CS
T-1
33 D
ataB
ase
Lab
s
The Muggwump Fish Farm DataBaseneeds to keep track of . . .
• Fish they sell– Fish Master
Muggwump
DataBase
• Customers they sell to– Customer Master
• Orders for Fish from Customers– Orders Data File
Click your left mouse button to proceed . . .
CS
T-1
33 D
ataB
ase
Lab
s Data Structures
• Each DataBase File has a name– E.G. Fish Master
• Each DataBase File is controlled by a Key– E.G. M Fish No
• Each Record is made up of Fields– E.G. Fish Description
• All names must be spelled exactly as shown– Capital letters where shown– Spaces where shown
Click your left mouse button to proceed . . .
Orders Fish Customer
Vendors Employee
Boats
CS
T-1
33 D
ataB
ase
Lab
s
I needcustomer
number 40
The Key
• Uniquely identifies each record of a database– Cannot be duplicated– Keeps records in sequence
• Can be used to “find” a given record• It’s the “Key” to accessing a record
Muggwump
DataBase
Click your left mouse button to proceed . . .
CS
T-1
33 D
ataB
ase
Lab
s Fish Master
• Key: M Fish No– 4 Characters– E.G. CR1– E.G. XY1
• Other Fields:– Fish Description Quan On Hand Memo– Cost Price Wt at Maturity– Salt or Fresh Picture
Click your left mouse button to proceed . . .
You can find me here!
CS
T-1
33 D
ataB
ase
Lab
s Customer Master
• Other Fields:– C First Name City Balance– C Last Name State Credit Limit– Street Zip Memo
Click your left mouse button to proceed . . .
• Key: C Cust No– 4 Characters– E.G. 20– E.G. 30
CS
T-1
33 D
ataB
ase
Lab
s
– Ship Date– Quan Pur
– O Cust No
Orders Data File:
• Key: Order No– 4 Characters– E.G. F14– E.G. F15
Click your left mouse button to proceed . . .
What Fish was ordered?
by this Customer?How many?When?
• Other Fields:– O Fish No
3 Carp7/04
Muggwump
J. Doe
CS
T-1
33 D
ataB
ase
Lab
s Orders Data File
• Then we can get more info about:– The Fish
• From the Fish Master (e.g. Fish Description)
– The Customer• From the Customer Master (e.g. Customer Name)
Click your left mouse button to proceed . . .
• The Order can lead us to information about:– The Fish
• Using O Fish No
– The Customer• Using O Cust No
3 Carp7/04
Muggwump
J. Doe
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
Relational DataBase -- Tables
• We start with three tables already defined1 Fish Master2 Customer Master3 Orders
• We will add records to these tables• We will change records in these tables• We will ask questions -- queries• We will create reports
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
Query a DataBase Management System
• Ask a question of the DBMS
• The DBMS returns information
Carp?
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
QBE -- Query By Example• Suppose we want the First and Last Name
of a Customer and their City.
• Select the table that stores that information.
a) The Table is Customer Master
b) The First Name Field is C First Name
c) The Last Name Field is C Last Name
d) The City Field is City
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
Query: First & Last Names and City
1. Construct the Query --- Choose the Table: Customer Master
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
Query: First & Last Names and City
2. The Fields of the Customer Master are listeda) Select C First Nameb) Select C Last Namec) Select City
Get a Check Mark in the Show Box
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
Query: First & Last Names and City
3. Run the Query Click the Exclamation Point Button Results are in Answer Window
!
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
Query: First & Last Names and City: City is Hollywood
4. Can Supply Criteria Click in Criteria Cell – Key your Criteria Click the Exclamation Point Button New Results are in Answer Window
We asked for anyone living in Hollywood so we got Whoopi’s data
!
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
Criteria
• Key data you want to match– e.g. a specific City (Hollywood)– e.g. a specific fish Description (Carp)– e.g. a specific C First Name (Whoopi)– e.g. >500 (Credit Limit Greater Than 500) – e.g. <21 (Quan Pur Less Than 21)– e.g. a specific Zip code (48710)
CS
T-1
33 D
ataB
ase
Lab
s A Problem:
Muggwump
Fish Farm
is out of
Carp!
. . . We need to inform our customers!
Click your left mouse button to proceed . . .
CS
T-1
33 D
ataB
ase
Lab
s Click your left mouse button to proceed . . .
We Know Fish Description -- We Need Customer Name and Address
We know the Fish Description:
Carp
Leads to Fish Number in Fish Master:
M Fish No
Leads to orders for this fish in Orders:
O Fish No
Orders has Customer Number:
O Cust No
Customer Master has Customer Name and
Address
Leads to Customer in Customer Master:
C Cust No
CS
T-1
33 D
ataB
ase
Lab
s
!
Find the Fish Number for “Carp” . . .
1. We know the Fish Description -- we need the Fish Number
3. Supply the Fish Description: Carp
Click your left mouse button to proceed . . .
2. For the query, select the fields for Fish Number and Description
5. Query results are in the new window - - -
The Fish Number for “Carp” is “CR1”
Query theFish Master
4. Click the Run Query Icon -- the Exclamation Point! !
Carp
CS
T-1
33 D
ataB
ase
Lab
s
Find the order(s) for“CR1”(Carp) . . .
1. We know the Fish Number -- we need the orders for CR1
3. Supply the Fish Number: CR1
Click your left mouse button to proceed . . .
2. Query: Select Order #, Fish #, and Customer #
5. Query results are in the new window - - -
There is one order with the Order Number “F14” and the Customer Number “20”
Query theOrders File
!
4. Click the Run Query Icon -- the Exclamation Point! !
CR1
CS
T-1
33 D
ataB
ase
Lab
s
Query theCustomer Master
FindCustomer“20” . . .
1. We know the Customer # -- we need the Name & Address for “20”
3. Supply the Customer Number: 20
Click your left mouse button to proceed . . .
2. Query: Select Customer #, First & Last Name, Address
5. Query results are in the new window - - -
Customer #20 is Whoopi Goldberg who lives in Hollywood on Nun Such St.
!
4. Click the Run Query Icon -- the Exclamation Point! !
FindCustomer“20” . . .
Query theCustomer Master
20
CS
T-1
33 D
ataB
ase
Lab
s
“Carp” led us to “Whoopi Goldberg". . . We Did Three Queries
Query #1.The Fish Master gave us the Fish Number for “Carp”
Click your left mouse button to proceed . . .
Query #2.The Order File gave us the Customer Number for that Fish Number
Query #3.The Customer Master gave us the Name and Address for that Customer Number
We Did Three QueriesWhy not do one Query -- and let the DBMS do more of the work for us !
CS
T-1
33 D
ataB
ase
Lab
s
Tables can be joined . . .
Click your left mouse button to proceed . . .
CustomerMaster
Orders
Cu
stom
er #
Use fields containing same data in each
table (Fish Number)
-- get GUI joining line
Use fields containing same data in each
table (Customer Number)
-- get GUI joining line
FishMaster F
ish
#
CS
T-1
33 D
ataB
ase
Lab
s
Who ordered “Carp” ?
Click your left mouse button to proceed . . .
Query allThree Tables
1. Start building the Query using the Fish Master Table
3. Select the desired fields & key Fish Description as “Carp”
2. In The Show Table Window, Add the Orders and CustomerMaster tables
Carp
CS
T-1
33 D
ataB
ase
Lab
s
Who ordered “Carp” ?
Click your left mouse button to proceed . . .
Query allThree Tables
Carp
6. Observe the GUI Connector Lines
5. Join Orders File and the Customer Master – drag C Cust No to O Cust No
4. Join the Fish Master and the Orders File – drag M Fish No to O Fish No
CS
T-1
33 D
ataB
ase
Lab
s
Who ordered “Carp” ?
Click your left mouse button to proceed . . .
Query allThree Tables
Carp
9. “Carp” led us to Whoopi Goldberg with one query
8. Query results are in the new window --- from all three tables --- they were joined
!
7. Click the Run Query icon
!
CS
T-1
33 D
ataB
ase
Lab
s
Exit from PowerPoint Viewer and start your DataBase Labs after this slide . . .
Click your left mouse button to return to the PowerPoint Viewer . . .
CustomerMaster
Orders
Cu
stom
er #
FishMaster
Boat FL
Fis
h #
Boat #
Then you will design and create a new table
to keep track of the boats that Muggwump Fish Farm uses to fill
orders
You will modify existing tables and be
led through some queries and reports
and create some charts
© Delta College CST Faculty