Download MIS 320 - Western Washington University

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

Serializability wikipedia , lookup

Microsoft Access wikipedia , lookup

Open Database Connectivity wikipedia , lookup

IMDb wikipedia , lookup

Oracle Database wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Ingres (database) wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Concurrency control wikipedia , lookup

Functional Database Model wikipedia , lookup

Database wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

ContactPoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
Database Design
MIS 320
Kraig Pencil
Summer 2013
1
PPT Slides by Dr. Craig Tyran & Kraig Pencil
Game Plan
• Introduction
• Data base design
– Database scenario
– Key questions/answers
2
PPT Slides by Dr. Craig Tyran & Kraig Pencil
A. Introduction
Remember … ?
CNN: Internet is “Top innovation” of past 25 years (1/18/05)
But Kraig Pencil says …
The relational database is equally important
Really? Why?
The Internet would not be nearly as successful without
relational databases providing rich information.
3
PPT Slides by Dr. Craig Tyran & Kraig Pencil
A. Introduction
You can ask a database questions
–
–
–
–
How many cans of chicken soup do we have in inventory?
How large is the average pay raise in each department?
Who are my best/worst customers?
What else have I-Pod buyers also purchased?
– Is this airline passenger a known terrorist?
– Who has friended Gayle Zhang?
– Who else might Gayle want to consider friending?
With the right data and a well-designed database, you can ask
4
anything.
PPT Slides by Dr. Craig Tyran & Kraig Pencil
A. Introduction
Who works with databases?
• Database programmers
• Database analysts
• Database designers
• Database administrators
• Data administrators
• Website designers/programmers
• Many non-IT users!
– Marketers
– Financial analysts
– Human resources managers …. And more
PPT Slides by Dr. Craig Tyran & Kraig Pencil
5
A. Introduction
1.
2.
What does an organization do with
data/information?
•
Capture, cradle, and process transaction
data/information
• e.g., TPS
•
Use information to make decisions
• e.g., DSS
•
“Oversee” the information
• e.g., Who can view or use what info?, How to
back up info?, How long to retain info?
What can help support the above?
• A database management system
PPT Slides by Dr. Craig Tyran & Kraig Pencil
6
B. Business Scenario
1. Is data management a problem?
For generations we stored information in filing cabinets, then
in Excel spreadsheets. But as the amount of data has grown
those methods have become …
– Inefficient – and expensive – to store and gather data
– Unable to support for decision making based
on data
 A database management system is
needed to support business !!!
PPT Slides by Dr. Craig Tyran & Kraig Pencil
B. Business Scenario
1. Northwind Incorporated
– Distributor of food and beverage products
– Customers: Restaurants and specialty food stores
– Suppliers: Come from around the world
– In the lab and lectures, you will see
how efficiently a database management system
can provide rich information to the
organization.
PPT Slides by Dr. Craig Tyran & Kraig Pencil
C. Steps of Database Design
1.
What kinds of “things” does an organization
want to collect information about?
 Determine the Entities
•
For Northwind Inc, the “entities” of
interest include:
– Customers
– Suppliers
– Employees
– Products
– Etc.
PPT Slides by Dr. Craig Tyran & Kraig Pencil
C. Steps of Database Design (cont.)
2. What specific information about each
entity is important?
 Determine the attributes for each entity
•
Example: For the Employee entity,
attributes may include
•
•
•
•
•
Employee name
Address
Hourly rate
Etc.
For each
employee, we
keep track of …
President of
Northwind
Who is this guy doing the interview?
•
A “business analyst”
10
PPT Slides by Dr. Craig Tyran & Kraig Pencil
C. Steps of Database Design (cont.)
3. How do we organize the data? Which type of database
“model” shall we use?
– Assume: Use the most popular model
•  Relational model
• “Relation” refers to ???
• Data is organized as a linked set of tables
• An example of a relational database
management system that you are using
in MIS 320 : ___________
11
PPT Slides by Dr. Craig Tyran & Kraig Pencil
Northwind Database in MS Access
Sample
Entity-Relationship Diagram
(aka an “ERD” or
“ER diagram”)
PPT Slides by Dr. Craig Tyran & Kraig Pencil
B. Database Questions (cont.)
4. What are the important aspects of a data table?
Find all records in the
–
Terminology for data tables
Customer file for which
• Field (i.e. column)
the customer’s name field
– Attribute of the entity
is Serena Lewis
• Record (i.e. row)
– An instance of an entity
• File (i.e., table)
– Collection of records for an entity
• Primary key
– Unique identifier for each record
– Often a unique “ID code” is created
–
Example: See next figure
PPT Slides by Dr. Craig Tyran & Kraig Pencil
13
Database Tables
What are examples of a) Field, b) Record, c) File,
and d) appropriate Primary Key ??
Supplier Table
Supplier ID
Company Name
Street Address
City
State
1001
ACME Inc.
123 Easy St.
Deming
WA
1002
XYZ Corporation
456 Maple St.
Bellingham
WA
1003
ProductCo Inc.
389 Main St.
Seattle
WA
…
Product Table
…
…
…
…
Product ID
Product Name
Unit Price ($)
Supplier ID
800
Cheddar Cheese
15
1001
801
Swiss Cheese
12
1001
802
Chuckanut Red
Wine
20
1002
…
PPT Slides by Dr. Craig Tyran & Kraig Pencil
….
….
…
C. Steps of Database Design (cont.)
5. What are the relationships between the entities?
–
–
A database involves tables that are linked together
When building a database, we need to know how to link the
tables
• i.e., We need to know how the entities are related!
•
–
e.g., A Supplier provides a Product.
– If we know who the supplier is, we
can find all the products they have
supplied to us.
– For any product, we should be able
to find the supplier’s address.
Develop a “blueprint” diagram
for database design
 Entity-relationship diagram
PPT Slides by Dr. Craig Tyran & Kraig Pencil
15
B. Database Questions (cont.)
5. What are the relationships between the entities? (cont.)
– Possible “relationship types”
•
–
A) one to one, B) one to many, c) many to many
– “one” means “at most one”
– “many” means “more than one”
Example:
•
•
•
Entities: Supplier, Product
What is the relationship type? We are told that:
– A supplier can provide many different kinds of products.
– A product can be supplied by a max of one supplier.
Entity-Relationship Diagram:
Supplier
one
???
PPT Slides by Dr. Craig Tyran & Kraig Pencil
many
???
Provides
Product
16
B. Database Questions (cont.)
5. Relationship symbols: these all mean the same thing
The textbook used “crowsfoot” symbols
One
Many
Ignore these “inner” symbols
Access uses “1 – ∞” symbols
Access uses “
– ∞” symbols
PPT Slides by Dr. Craig Tyran & Kraig Pencil
B. Database Questions (cont.)
5. (cont.)
–
Foreign key
•
•
•
Serves as a “link” between data files/tables
A field in one file/table that serves as a primary
key in another file/table
How to determine the foreign key?
– For a “one to many” relationship, the primary key on the
“one” side of the relationship is added to the table on the
“many” side
•
See examples
18
PPT Slides by Dr. Craig Tyran & Kraig Pencil
Database Tables: Northwest Inc.
Supplier
Table
Supplier ID
Company Name
Street Address
City
State
1001
ACME Inc.
123 Easy St.
Deming
WA
1002
XYZ Corporation
456 Maple St.
Bellingham
WA
1003
ProductCo Inc.
389 Main St.
Seattle
WA
…
Product
Table
…
…
…
…
Product ID
Product Name
Unit Price ($)
Supplier ID
Category ID
800
Cheddar Cheese
15
1001
10
801
Swiss Cheese
12
1001
10
802
Chuckanut Red
Wine
20
1002
20
…
Category Table
….
….
…
…
Category ID
Category Name
Description
10
Dairy
Cheese and milk products
20
Spirits
Wine and liquors
…
PPT Slides by Dr. Craig Tyran & Kraig Pencil
…
…
Northwind Database in MS Access: Primary/Foreign Keys
Where are the primary keys? The foreign keys?
PPT Slides by Dr. Craig Tyran & Kraig Pencil
C. Steps of Database Design (cont.)
6. What do we do with the entity-relationship
diagram? (cont.)
–
–
–
ERD can be reviewed with client (Is the
design correct for the client’s needs?)
Database design can be used to build the
database
• e.g., Build database in MS Access
Can database design get more complicated
than this?
• Yes!
• But … the previous example will suffice
for MIS 320
– The lab database projects will
typically focus on “one to many”
types of relationships
21
PPT Slides by Dr. Craig Tyran & Kraig Pencil
Terminology Summary
Easy to
understand
Academic
Table
(File)
Entity / Relation
Column
Field
Attribute
Row
Record
Instance
The terms in each row have
very similar meanings.
For this course, learn all of
the terms, but do not be
concerned about the nuanced
differences between terms in
the same row.
22
PPT Slides by Dr. Craig Tyran & Kraig Pencil