Download kroenke_emis3_ch05

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Chapter 5
Database Processing
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
2
What Is the Purpose of a Database?
•
Organize and keep track of things
•
Keep track of multiple themes
•
General rule:
 Single theme store in a spreadsheet
 Multiple themes require a database
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-3
A List of Student Grades Presented in a
Spreadsheet – Single Theme
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-4
Data Redundancy and Data Inconsistency
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5
Student Data Form With Multiple
Themes
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-6
Copyright © 2012 Pearson Education,
Inc. Publishing as Prentice Hall
7
Why we need databases
• Size
• Ease of Updating
• Accuracy
• Security
• Redundancy
• Importance
Copyright © 2012 Pearson Education,
Inc. Publishing as Prentice Hall
8
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
9
Components of a Database
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-10
Tables
Table or file:
A group of records
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-11
Tables (cont’d)
Each table must
have a unique
identifier called the
Primary Key (PK)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-12
More Special Terms
Relational
databases
Relation
•Relationships among tables are
created by using foreign keys
•Formal term for a table
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
1-13
Relationships Among Records
Database has multiple tables (one
for each theme)
Values in one table may relate to
records in other tables
Relational
database
Primary or
Unique key
Foreign key
Field(s) that uniquely
identify a record in a table
Each table must have a key
A non-primary key in one table
that is related to a primary key
of a different table
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-14
Primary and Foreign Keys
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-15
Metadata
Database: Self-describing collection of integrated records
Metadata
Describes data by:
•Data that describes data
•Makes databases more
useful
•Makes databases easier
to use
•Data type: text, number,
date, etc.
•Field name
•Field properties
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-16
Sample Metadata in Access
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-17
Features of Relational Databases
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-18
Features of Relational Databases
(cont’d)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-19
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
20
What Is a DBMS and What Does It Do?
Database management system (DBMS)
― Program that creates, processes, and administers
databases
― Examples:
Database
Collection of
tables,
relationships,
and
metadata
DBMS
A
software
program
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-21
Components of a Database Application
System
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-22
Processing the Database
Four DBMS operations
1. Read
2. Insert
3. Modify
4. Delete data
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-23
Structured Query Language (SQL)
•
SQL (see-quell)
• International standard
• Used by most popular DBMS
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-24
Structured Query Language (SQL)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-25
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
26
Database Applications
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-27
Forms, Reports, and Queries
Forms
• Used to read, insert, modify,
and delete data
Reports
• Show data in structured
context
• May compute values such as
Totals, within a report
Queries
• Are a means of getting
answers from database data
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-28
How Are Database Application Systems Developed?
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-29
How Are Database Application Systems Developed?
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-30
What Are the Components of the
Entity-Relationship Data (ERD) Model?
Entities
• Something users want to track
• Order, customer, salesperson, item,
volunteer, donation
Attributes
• Describe characteristics of an entity
• OrderNumber, CustomerNumber,
VolunteerName, PhoneNumber
Identifier
• Attribute that uniquely identifies one
entity instance from other instances
• Student_ID_Number
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
1-31
Creating ERDs
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-32
Student Data Model Entities
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-33
Example of Department, Adviser, and
Student Entities and Relationships
A
department
may have
many
advisers
An adviser
works in one
department
1:N relationships
An adviser
advises
many
students
A student
may have
one or more
advisers
N:M relationships
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-34
Example of Department, Adviser, and
Student Entities and Relationships
N:M
1:N
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-35
Entity Relationship Diagram (ERD) ― Version 1
Crow’s
Feet
1:N
1:N = one-to-many relationships
One department can have many
advisers, but an adviser is in
only one department
N:M
N:M = many-to-many
relationships
One adviser can have many
students and one student
can have many advisers
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-36
Entity Relationship Diagram (ERD) – Version 2
“Crow’s Foot”
N:M = many-to-many
relationship
1:N = one-to-many
relationship
A department has many
advisors and an advisor
may advise for more
than one department
A student has only one
advisor, but an adviser
may advise many
students
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-37
Defining one-to-many relationships
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-38
How Are Database Application Systems Developed?
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-39
Transforming a Data Model into a Database
Design
• Represent each entity with a table
‒ Entity identifier becomes table key
‒ Entity attributes become table columns
• Normalize tables as necessary
• Represent relationships
‒ Use foreign keys
‒ Create additional tables for N:M relationships
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-40
Representing 1:N Relationships
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-41
Exploring many-to-many relationships
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-42
Representing an N:M Relationship: Strategy
for Foreign Keys
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-43
How Are Database Application Systems Developed?
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
CE7-44
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
45
What Is the Difference Between an
Enterprise DBMS and a Personal DBMS?
Enterprise DBMS
Personal DBMS
• Processes large
organizational and
workgroup databases
• Supports many users
(thousands plus)
• Examples: DB2, SQL Server,
Oracle, MySQL
• Designed for smaller,
simpler database
applications
• Supports fewer than 100
users (mostly 1–10 users)
• Examples: Access, dBase,
FoxPro, R-Base
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
5-46
Related documents