Вы находитесь на странице: 1из 22

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 anything.
4
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
5
PPT Slides by Dr. Craig Tyran & Kraig Pencil

A. Introduction
What does an organization do with
data/information?

1.

2.

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

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 customers 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,
Supplier Table

and d) appropriate Primary Key ??

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 suppliers address.
Develop a blueprint diagram
for database design
Entity-relationship diagram

15
PPT Slides by Dr. Craig Tyran & Kraig Pencil

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

Provides

many
???

Product
16

B. Database Questions (cont.)


5. Relationship symbols: these all mean the same thing
The textbook used crowsfoot symbols
One

Access uses 1 symbols

Access uses

symbols

PPT Slides by Dr. Craig Tyran & Kraig Pencil

Many

Ignore these inner symbols

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 entityrelationship diagram? (cont.)

ERD can be reviewed with client (Is the


design correct for the clients 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

PPT Slides by Dr. Craig Tyran & Kraig Pencil

21

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

Вам также может понравиться