an introduction to databases january 14, 2010. groups 21 people = 3 4 person groups and 3 3 person...

25
An Introduction to Databases January 14, 2010

Upload: shauna-nicholson

Post on 19-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

An Introduction to Databases

January 14, 2010

Page 2: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Groups 21 people = 3 4 person groups and 3 3 person

groups

Group roles – These may rotate during the semester “Secretary/Recorder” – person to document decisions

made by the group. This person should carefully document team member responsibilities as defined in the meeting.

“Chair/Coordinator” – person responsible for keeping the meetings going. Keeps the group from getting too far off track. (Some socialization is good and important, but too much can keep you from meeting your goals.)

Contact person – the person responsible for contacting customers or “surrogates”. (I don’t want questions coming from many different people.)

Page 3: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

And the groups are: Friday – early afternoon – Cordazzi, Lloyd,

Coles, Tucker Sunday – 3 – 6 – Brubaker, Tian, Dunaway Wednesday – 3 – 6 – Stacey, Kim, Ringers,

Hubbard Wednesday – 3 – 6 – Vandenberger, Miles,

Danielson Sunday – 6 – 10 – Stanley, Foster, Luong,

Smith Thursday – 6 – 10 – Ford, Holt, Onat

Page 4: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

In your groups Find out a little bit about each other. Trade contact information. Confirm the official time for team meetings.

You may want to use those meetings to prepare homework as well as to work on the project. You will turn in individual homework, but may work on it together.

Choose a team / company name. This will be your software company name and will be used through the semester.

Page 5: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

In your groups Create a Team Expectation Agreement

This document will list the expected behavior of team members both inside of class when doing group work and outside of class when working on homework and project work.

Examples: Team members will make sure that we all attend class each

day. We will make sure that each team member contributes in some

way to each group meeting. We agree to let each other know if one person is monopolizing

the conversations in class. Assign to the recorder the task of recording the group

agreement. The recorder should then send an electronic copy to each of the group members for approval. When done, send one copy to me. (Due Tuesday)

Page 6: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Which project? In your groups, discuss which project you

would find most interesting.

Let’s discuss as a class

Page 7: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Questions about contract grades? Fill out a contract (found under assignments)

and return no later than Tuesday.

You will be able to change your contract once during the first half of the semester (before spring break).

Page 8: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Evaluation Team members will evaluate the effectiveness

of each member of the team. If an individual is not contributing to the project, they should not receive the same grade as those that do.

We will do an early evaluation after the project begins and then do a final one as the project is turned in. The project grade will be based on the quality of the project (group grade) and the value of the contribution of the individual.

Page 9: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

An introduction to database systems Here are some examples of computer

database applications E-campus (PeopleSoft) Blackboard E-commerce (Amazon.com) Library

What attributes do these systems all share?

Page 10: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

More formal definitions A collection of related data.

Card catalog Recipe file Phone directory

A collection of related data stored in a computer system.

Definition from my old book. This data simulates some real world entities. It

usually is used to focus on how those entities are used within a particular process.

The entities are related to one another. Teacher – Class Student – Class The relationships may be one to one (One person has at

most one spouse), one to many (one teacher may have many classes) or many to many (one customer may buy many items and each item may be bought by many customers)

Page 11: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

More about database properties The data in a database should be logically

related (we talk about integrated databases). The data should have meaning to its user

community. The data should be useful to someone within

the user community. Databases are not static collections of data.

The data changes over time. The database design should be based on how the data will be used.

Page 12: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Information vs data Data is the raw values. For example 3 is data.

But what does it mean? Your GPA? Interest rate percentage? Average life expectancy of an American Newt

(http://www.myuniversalfacts.com/2007/01/life-span-of-animals-how-long-do.html)

Databases provide structure to data which helps us to understand the data in its context.

The data becomes information when its meaning is understood.

Page 13: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Properties of databases Data is integrated Data is shared among many users Data has persistence – it lives over a period of

time Data is not duplicated to the extent possible Data is stored in raw form and then is

processed

Page 14: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

DBMS Database Management Systems

Manage the database Provide an application that lets DBAs manipulate the

database DBA is Database Administrator

Database Management System features Provide a mechanism for defining the data (meta-

data) Provide a mechanism for protecting the data Provide a query mechanism for accessing the data

Applications can interact with the DBMS to perform database actions.

Page 15: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Why DBMS Efficient way to manage data Prevent data redundancy (data found in

several places – sometimes inconsistently) Enforce security constraints – provide different

views Student user has one level of access Professors have another Database administrator has another

Enforce “business rules” of the organization Dates should be dates Grades must be particular values only

Page 16: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

People End users

Casual users (use queries) Naïve users (use applications) Secondary users (use output from db)

Applications programmers Write the applications that interact with the database

Data administrator Designs, creates and maintains the database Implements the technical controls to enforce policies

Database Administrator Strategy decisions, policy decisions

Page 17: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

A database system Diagram

Components – users Data layer – resides on the physical hardware DBMS – provides the interface to the physical

data

Page 18: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

DBMS Categories

Model Hierarchical – Tree like structure – parent to child segments –

one to many. Network – Like hierarchical but with the possibility of many to

many relationships. Relational – 1970 – Codd – The data is represented as a series

of related tables. Object Oriented – Relational but with the inclusion of methods

to form full objects. Users

Single user at a time Multiple users

Sites Centralized Distributed – database or parts are divided up into multiple

locales Client/server – central data but applications run on local

machines

Page 19: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Example – Marina Service BusinessMarina Number Name Warranty

Non-warranty Last Name First Name

Hourly Rate

YTD Earnings

FB96Fenton's Boats $923.20 $657.50Anderson Trista $24.00 $17,862.00

NW72Nelson's Wharf $608.50 $520.00Anderson Trista $24.00 $17,862.00

AN75Afton's Marina $1,906.50 $831.25Nichols Ashton $21.00 $19,560.00

BL72Brite's Landing $217.00 $0.00Nichols Ashton $21.00 $19,560.00

FM22Fedder Marina $432.00 $0.00Nichols Ashton $21.00 $19,560.00

JB92 JT Boat Club $0.00 $0.00Nichols Ashton $21.00 $19,560.00

TR72 The Reef $219.00 $0.00Nichols Ashton $21.00 $19,560.00

TT75 The Teacup $0.00 $0.00    

AD57 Alan's Docks $1,248.00 $597.75Gomez Teresa $22.00 $21,211.50

EL25Elend Marina $413.50 $678.75Gomez Teresa $22.00 $21,211.50

SM72Solton's Marina $462.50 $295.00Gomez Teresa $22.00 $21,211.50

What’s wrong with this picture?

Page 20: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Two tables, Marina…Marina Number Name Address City State Zip Code Warranty

Non-warranty

Tech Number

AD57 Alan's Docks 314 Central Burton MI 49611 $1,248.00 $597.7549

AN75Afton's Marina 21 West 8th Glenview MI 48121 $1,906.50 $831.2536

BL72Brite's Landing 281 Robin Burton MI 49611 $217.00 $0.0036

EL25Elend Marina 462 River Torino MI 48268 $413.50 $678.7549

FB96Fenton's Boats 36 Bayview Cavela MI 47926 $923.20 $657.5023

FM22Fedder Marina

283 Waterfront Burton MI 49611 $432.00 $0.0036

JB92 JT Boat Club28 Causeway Torino MI 48268 $0.00 $0.0036

NW72Nelson's Wharf 27 Lake Masondale MI 49832 $608.50 $520.0023

SM72Solton's Marina

867 Bay Ridge Glenview MI 48121 $462.50 $295.0049

TR72 The Reef 92 East Bay Woodview MI 47212 $219.00 $0.0036TT75 The Teacup         $0.00 $0.0048

Page 21: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

And the Technician table

TechnicianTech Number

Last Name

First Name

Address City State Zip CodeHourly Rate

YTD Earnings

23 Anderson Trista 283 Belton Port Anton

MI 47989 $24.00 $17,862.00

36 Nichols Ashton 978 Richmond

Hewitt MI 47618 $21.00 $19,560.00

49 Gomez Teresa 2855 Parry Ashley MI 47711 $22.00 $21,211.50

Page 22: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

ConnectionMarina Number Name Address City State Zip Code Warranty

Non-warranty

Tech Number

AD57 Alan's Docks 314 Central Burton MI 49611 $1,248.00 $597.7549

AN75Afton's Marina 21 West 8th Glenview MI 48121 $1,906.50 $831.2536

BL72Brite's Landing 281 Robin Burton MI 49611 $217.00 $0.0036

EL25Elend Marina 462 River Torino MI 48268 $413.50 $678.7549

FB96Fenton's Boats 36 Bayview Cavela MI 47926 $923.20 $657.5023

FM22Fedder Marina

283 Waterfront Burton MI 49611 $432.00 $0.0036

JB92 JT Boat Club28 Causeway Torino MI 48268 $0.00 $0.0036

NW72Nelson's Wharf 27 Lake Masondale MI 49832 $608.50 $520.0023

SM72Solton's Marina

867 Bay Ridge Glenview MI 48121 $462.50 $295.0049

TR72 The Reef 92 East Bay Woodview MI 47212 $219.00 $0.0036TT75 The Teacup         $0.00 $0.0048

Page 23: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Tech number

TechnicianTech Number

Last Name

First Name

Address City State Zip CodeHourly Rate

YTD Earnings

23 Anderson Trista 283 Belton Port Anton

MI 47989 $24.00 $17,862.00

36 Nichols Ashton 978 Richmond

Hewitt MI 47618 $21.00 $19,560.00

49 Gomez Teresa 2855 Parry Ashley MI 47711 $22.00 $21,211.50

The Tech Number in the Marina table is a Foreign Key to the unique identifier in the Technician table.

Page 24: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

What do we want to see? A list of the names and warrantee amounts

from the table

A list of all of the zip codes from the marinas

A list of all of the marinas with warrantees

A list of all of the cities where marinas from Michigan are located sorted by city name

Page 25: An Introduction to Databases January 14, 2010. Groups  21 people = 3 4 person groups and 3 3 person groups  Group roles – These may rotate during the

Basic queriesGiven the Marina Table – what do we get? SELECT name, warranty FROM Marina

SELECT zip code FROM Marina

SELECT name FROM Marina WHERE warranty > 0

SELECT city FROM Marina WHERE state = “MI” ORDER BY city