In this chapter, students will be able to understand: How do you process the data from transactions and integrate the operations of the organization? How do you efficiently collect transaction data? What are the major elements and risks of a transaction?,...
Trang 1Introduction to MIS
Chapter 6 Database Management Systems
Trang 2Database Management Systems
Database DBMS Programs
Sales and transaction data Reports and
ad hoc queries
Trang 4DBMS & People
Data
DatabaseManagementSystemProgram Program
Business Operations
Ad Hoc Queries and Reports
Trang 5Phone Name Address City312-555-1234 Jones 123 Main Chicago502-555-8876 Smith 456 Oak Glasgow602-555-9987 Juarez 887 Ribera Phoenix612-555-4325 Olsen 465 Thor Minneapolis
Customer Table
Customer Date Salesperson Total_sale502-555-8876 3/3/04 2223 157.92602-555-9987 4/4/04 8876 295.53612-555-4325 4/9/04 8876 132.94502-555-8876 5/7/04 3345 183.67
Trang 6Invoice Program
Billing Program
Data and programs
Undocumented files
Files & many programs
Multiuser
Changes
Trang 7All Data Files
Database Management
System
Invoice Program
Billing Program
Trang 81) What output do you want to see?
2) What tables are involved?
3) What do you already know? (constraints) 4) How are the tables joined?
Four questions to create a query
Database Queries
Single Table
Computations
Joining Tables
Trang 9Single Table Query Introduction
Access Query Screen (QBE)
Query: Which customers have balances greater than $200?
File: C05E15a.mdb
Trang 10“AND” Conditions and Sorting
Sample Data
Access Query Screen (QBE)
Query: Which Denver customers have balances greater than $200?
28764 Adamz 602-999-2539 Phoenix 197.54
87535 James 305-777-2235 Miami 255.93
44453 Kolke 303-888-8876 Denver 863.39
29587 Smitz 206-676-7763 Seattle 353.76
Trang 11SQL Introduction
Query: Which customers have balances greater than $200?
SQL: SELECT CID, Name, Phone, City, AccountBalance
FROM Customers WHERE AccountBalance > 200 ;
Query: Which Denver customers have balances greater than $200?
SQL: SELECT CID, City, AccountBalancel
FROM Customers WHERE AccountBalance > 200 and City = “Denver”
28764 Adamz 602-999-2539 Phoenix 197.54
87535 James 305-777-2235 Miami 255.93
44453 Kolke 303-888-8876 Denver 863.39
29587 Smitz 206-676-7763 Seattle 353.76
Trang 12Useful WHERE Conditions
Match all Name LIKE “J*”
Match one Name LIKE “?m*”
Use with QBE or SQL
Trang 15Sample Output
Trang 16Groups with Conditions
Query: What is the average account balance for customers from Denver?
Trang 18Linking Tables
The Orders to ItemsSold relationship enforces referential integrity.
Trang 19Query Example
Which customers (CID) have placed
orders since June 1, 2004?
Trang 21SELECT DISTINCT Salespeople.Name,
Customers.Name FROM Salespeople INNER JOIN (Customers INNER JOIN Orders ON
Customers.CID=Orders.CID) ON Salespeople.SID = Orders.SID ORDER BY Salespeople.Name ;
List the salespeople (sorted alphabetically) along
with the names of customers who placed orders
with that salesperson.
Trang 23Database Design
One value per cell
key and nothing but the key.
Trang 24Database Design: Normalization
File: C05Vid.mdb
Trang 25Table name
Primary key is underlined
Table columns
Customer (CustomerID, Phone, Name, Address, City, State, ZipCode)
CustomerID Phone LastName FirstName Address City State ZipCode
3 502-777-7575 Washington Elroy 95 Easy Street Smith's Grove KY 42171
5 502-474-4746 Rabitz Victor 645 White Avenue Bowling Green KY 42102
6 615-373-4746 Steinmetz Susan 15 Speedway Drive Portland TN 37148
8 615-452-1162 Jones Charlie 867 Lakeside Drive Castalian Springs TN 37031
9 502-222-4351 Chavez Juan 673 Industry Blvd Caneyville KY 42721
Trang 261st: Repeating
RentalForm(TransID, RentDate, CustomerID, Phone, Name, Address, City, State, ZipCode, (VideoID, Copy#, Title, Rent ) )
Repeating Section
Causes duplication
TransID RentDate CustomerID LastName Phone Address VideoID Copy# Title Rent
1 4/18/04 3 Washington 502-777-7575 95 Easy Street 1 2 2001: A Space Odyssey $1.50
1 4/18/04 3 Washington 502-777-7575 95 Easy Street 6 3 Clockwork Orange $1.50
2 4/30/04 7 Lasater 615-888-4474 67 S Ray Drive 8 1 Hopscotch $1.50
2 4/30/04 7 Lasater 615-888-4474 67 S Ray Drive 2 1 Apocalypse Now $2.00
2 4/30/04 7 Lasater 615-888-4474 67 S Ray Drive 6 1 Clockwork Orange $1.50
3 4/18/04 8 Jones 615-452-1162 867 Lakeside Drive 9 1 Luggage Of The Gods $2.50
3 4/18/04 8 Jones 615-452-1162 867 Lakeside Drive 15 1 Fabulous Baker Boys $2.00
3 4/18/04 8 Jones 615-452-1162 867 Lakeside Drive 4 1 Boy And His Dog $2.50
4 4/18/04 3 Washington 502-777-7575 95 Easy Street 3 1 Blues Brothers $2.00
4 4/18/04 3 Washington 502-777-7575 95 Easy Street 8 1 Hopscotch $1.50
4 4/18/04 3 Washington 502-777-7575 95 Easy Street 13 1 Surf Nazis Must Die $2.50
4 4/18/04 3 Washington 502-777-7575 95 Easy Street 17 1 Witches of Eastwick $2.00
Trang 27First Normal
Customer Rentals
Name Phone Address City State ZipCode
VideoID Copy# Title Rent
Trang 281st: Split
RentalForm(TransID, RentDate, CustomerID, Phone, Name, Address, City, State, ZipCode, (VideoID, Copy#, Title, Rent ) )
RentalForm2(TransID, RentDate, CustomerID, Phone, Name, Address, City, State, ZipCode)
RentalLine(TransID, VideoID, Copy#, Title, Rent )
TransID RentDate CustomerID Phone LastName FirstName Address City State ZipCode
1 4/18/04 3 502-777-7575 Washington Elroy 95 Easy Street Smith's Grove KY 42171
2 4/30/04 7 615-888-4474 Lasater Les 67 S Ray Drive Portland TN 37148
3 4/18/04 8 615-452-1162 Jones Charlie 867 Lakeside Drive Castalian Springs TN 37031
4 4/18/04 3 502-777-7575 Washington Elroy 95 Easy Street Smith's Grove KY 42171
RentalLine
Note: replication
Note: replication
Trang 292nd Split
RentalLine(TransID, VideoID, Copy#, Title, Rent )
VideosRented(TransID, VideoID, Copy# ) Videos(VideoID, Title, Rent )
TransID VideoID Copy#
Trang 303rd Split
RentalForm2(TransID, RentDate, CustomerID, Phone, Name, Address, City, State, ZipCode )
Rentals(TransID, RentDate, CustomerID )
Customers(CustomerID, Phone, Name, Address, City, State, ZipCode )
TransID RentDate CustomerID
CustomerID Phone LastName FirstName Address City State ZipCode
1 5026667777 Johnson Martha 125 Main Street Alvaton KY 42122
2 5028886464 Smith Jack 873 Elm Street Bowling Green KY 42101
4 5023339494 Adams Samuel 746 Brown Drive Alvaton KY 42122
5 5024744746 Rabitz Victor 645 White Avenue Bowling Green KY 42102
Rentals
Customers
Trang 313NF Tables
Trang 32DBMS Input Screen
Text/Labels Data Variables
Command Buttons
Trang 34Sample Report
with Groups
Trang 35Designing Menus for Users
Customer Information
As a secretary, which menu is easier to understand?
Trang 375) Calculate total6) Sort for highest total
7) Look up names
Database versus Spreadsheet
Trang 38Storage v calculation Multiple tables
Trang 39 Hypertext & Massive text
Pictures & Graphs
Objects
User defined
Trang 42page
Trang 43Cases: Airlines
Trang 44Cases: American Airlines
Southwest Airlines
What is the company’s current status?
What is the Internet strategy?
How does the company use information technology?
www.americanair.com
www.iflyswa.com
Trang 45Appendix: Building Forms in Access
Trang 46Selecting Columns
Select additional data from the other tables But be careful with key
columns For example, do not include the CustomerID from the
Customer table or the ItemID from the Item table Instead, use
Trang 47Form Wizard: First Pass
The wizard builds the Sale form with a sub form to enter
multiple Items being sold But it needs some work with layout.
Trang 48Form Design View
In design view, you can move the labels and boxes to make the form
Trang 49Form Design: Sub Form and SubTotal
Edit the subform and add a Combo box for ItemID Delete the Description box Add
an ItemValue text box to multiply Quantity * List Price Add a text box to compute the subtotal [=Sum([Quantity]*[ListPrice])] Be sure to set the correct names and formats
Trang 50Sale Form
The final sale form adds a text box that copies the subtotal from the sub
form to the main form Just add a text box and set its value to
=[SaleItem Subform].[Form].[SubTotal]