47
MIS 111: COMPUTERS AND THE INTER-NETWORKED SOCIETY Class 9: Database Management Systems July 21 st , 2011

MIS 111: Computers and the inter-networked society

  • Upload
    chaela

  • View
    36

  • Download
    0

Embed Size (px)

DESCRIPTION

MIS 111: Computers and the inter-networked society. Class 9: Database Management Systems July 21 st , 2011. Class project. Looks great! Google analytics… now what? I want you to check Google analytics and see who is visiting your Web site. - PowerPoint PPT Presentation

Citation preview

Page 1: MIS 111:  Computers and the inter-networked society

MIS 111: COMPUTERS AND

THE INTER-NETWORKED

SOCIETYClass 9: Database Management

SystemsJuly 21st, 2011

Page 2: MIS 111:  Computers and the inter-networked society
Page 3: MIS 111:  Computers and the inter-networked society

CLASS PROJECT Looks great! Google analytics… now what? I want you to check Google analytics

and see who is visiting your Web site. At the end of the semester, we’ll see who

has the most visitors! How do I get people to my site: see SEO

slides; submit to Google, yahoo.

Page 4: MIS 111:  Computers and the inter-networked society

ADMINISTRATION Visio stencil on my Web site for ER

diagrams

Page 5: MIS 111:  Computers and the inter-networked society

LEARNING OBJECTIVES List a few current events in information

systems news Construct and ER diagram (Recap) Use vLookup in excel to mimic a

relational database Convert an ER diagram to a relational

database scheme

Page 6: MIS 111:  Computers and the inter-networked society

ER DIAGRAM RECAP

Page 7: MIS 111:  Computers and the inter-networked society

WHAT ARE THE STEPS IN DEVELOPING AN ER DIAGRAM Twinkle Tones School of Music provides

private lessons only by musician request. When a musician requests a private lesson, the School finds an available instructor and arranges a lesson schedule.

The School would like to track these lessons – the day of the week when they are scheduled, as well as the time they begin.

The School would also like to track musician names and email addresses, as well as instructor names and email addresses.

Page 8: MIS 111:  Computers and the inter-networked society

INSTRUCTORS Musiciansteach

LESSONS

MusIDMusNam

e

MusEmail

InsID

InsEmailInsName

TimeDay

[0:M]

[1:1]

[1:1]

TWINKLE TONES PRIVATE LESSONS

Page 9: MIS 111:  Computers and the inter-networked society

TEAMS

Aggregate

STUDENTS

TEACHERS

[2:5][1:1]

[0:M]

[1:3]

AGGREGATE CLASSES REVISITED

TeamIdTeamNam

e

StudentId

Name

TeacherId

Page 10: MIS 111:  Computers and the inter-networked society

RELATIONAL TABLES

Page 11: MIS 111:  Computers and the inter-networked society

RELATIONAL TABLES We can use the entity relationship

diagrams we design to create relational tables that can be stored in a database.

NOTE: A relational database is not just a table of information. It consists of multiple tables that reference one another.

Page 12: MIS 111:  Computers and the inter-networked society

WHAT IS A RELATIONAL TABLE?? Let’s mimic one together in Excel and

vLookup Download excel sheet from:

http://www.u.arizona.edu/~jjenkins/mis111_summer2011/example%20data.xlsx

Page 13: MIS 111:  Computers and the inter-networked society

A LITTLE HISTORY ON THE RELATIONAL MODEL

Desktop

My Documents

My Network Places

MIS 111 CMI My Pictures

July 13.pp

t

Class Roster.doc

Page 14: MIS 111:  Computers and the inter-networked society

THE HIERARCHICAL MODEL

Page 15: MIS 111:  Computers and the inter-networked society

EDGAR FRANK "TED" CODDWAS UNIMPRESSED In the 1960s, a man working for IBM

decided that he could improve upon hierarchical data storage.

He knew that the hierarchical model led to data redundancy and confusion. We always have to start at the top

node. That makes looking for the data I need take forever!

Sometimes I end up with the same data saved in different places! If I need to update that data, I need to do it in multiple places!

1923-2003

Page 16: MIS 111:  Computers and the inter-networked society

CODD’S NORMAL FORMS (RULES) 1st normal form (Rule 1)

No repeating elements or groups of elements

Take from http://www.phlonx.com/resources/nf3/

Page 17: MIS 111:  Computers and the inter-networked society

CODD’S NORMAL FORMS (RULES) 2nd normal form (Rule 2)

No partial dependencies on a concatenated key

Take from http://www.phlonx.com/resources/nf3/

Page 18: MIS 111:  Computers and the inter-networked society

CODD’S NORMAL FORMS (RULES) 3rd normal form (Rule 3)

No dependencies on non-key attributes

Take from http://www.phlonx.com/resources/nf3/

Page 19: MIS 111:  Computers and the inter-networked society

SOME GOOD NEWS ER diagrams were developed a few

years after Codd If the ER diagram was developed

correctly, we are automatically in 3rd Normal Form!!!

Page 20: MIS 111:  Computers and the inter-networked society

REVIEW SOME TERMINOLOGY

Page 21: MIS 111:  Computers and the inter-networked society

MANY-TO-MANY We call this in general a “many-to-

many” relationship because each entity class may have more than one instance.

Many-to-many = [M:N]

[0:30]STUDENTS COURSESenroll

in[4:6]

Page 22: MIS 111:  Computers and the inter-networked society

ONE-TO-MANY We call this in general a “one-to-many”

relationship because one side may only have up to one instance and the other may have many.

One-to-Many = [1:M]

COURSES

TEACHERS

teach

[0:1]

[1:3]

Page 23: MIS 111:  Computers and the inter-networked society

ONE-TO-ONE We call this in general a “one-to-one”

relationship because both entity classes may only have a maximum of one instance.

One-to-one = [1:1]

DOCTORS PATIENTStreat

[1:1] [1:1]

Page 24: MIS 111:  Computers and the inter-networked society

TEACHERS, STUDENTS, AND COURSES

Remember this?

STUDENTS

COURSES

enroll in

CourseNo CourseNam

eStudentNam

e

StudentEmail

TEACHERSteac

h

TeacherID

TeacherName

TeacherEmail

TeacherSalary

StudentID[0:1]

[1:3][0:30]

[4:6]

Page 25: MIS 111:  Computers and the inter-networked society

STEPS TO CONVERT AN ERD TO A SET OF RELATIONAL TABLES 1. For every strong entity class, create

a table or relation. The identifier becomes what is called a

primary key.The other attributes become what are

called non-key elements.

We can represent the STUDENTS table as such:

STUDENTS (StudentID, StudentName, StudentEmail)

Page 26: MIS 111:  Computers and the inter-networked society

YOU TRY: COURSES 1. For every strong entity class, create

a table or relation. The identifier becomes what is called a

primary key.The other attributes become what are

called non-key elements.

COURSES (CourseNo, CourseName)

Page 27: MIS 111:  Computers and the inter-networked society

YOU TRY: TEACHERS 1. For every strong entity class, create

a table or relation. The identifier becomes what is called a

primary key.The other attributes become what are

called non-key elements.

TEACHERS (TeacherID, TeacherName, TeacherEmail, TeacherSalary)

Page 28: MIS 111:  Computers and the inter-networked society

WHAT WE HAVE SO FAR TEACHERS (TeacherID, TeacherName,

TeacherEmail, TeacherSalary)

STUDENTS (StudentID, StudentName, StudentEmail)

COURSES (CourseNo, CourseName)

Page 29: MIS 111:  Computers and the inter-networked society

WHAT THIS WOULD ACTUALLY LOOK LIKE IN TABLE FORMStudentID StudentName StudentEmail

112923049 Smith [email protected] Jones [email protected]

uCourseNo CourseName

MIS111 CMP_INTRNTWKDMIS373 SYSTM_ANL_DSGNMIS696A RDNGS_IN_MIS

TeacherID TeacherName

TeacherEmail

TeacherSalary

13445 Killinger [email protected] Class_C

23489 Carl [email protected] Class_D

Page 30: MIS 111:  Computers and the inter-networked society

STEPS TO CONVERT AN ERD TO A SET OF RELATIONAL TABLES 2. Locate any [1:M] relationships

between strong entity classes.

STUDENTS

COURSES

enroll in

CourseNo CourseNam

eStudentNam

e

StudentEmail

TEACHERSteac

h

TeacherID

TeacherName

TeacherEmail

TeacherSalary

StudentID[0:1]

[1:3][0:30]

[4:6]

Page 31: MIS 111:  Computers and the inter-networked society

STEPS TO CONVERT AN ERD TO A SET OF RELATIONAL TABLES 2. Locate any one-to-many relationships

between strong entity classes. Put the primary key on the “1” side of the relationship into the table of the “M” side.

TEACHERS (TeacherID, TeacherName, TeacherEmail, TeacherSalary)

COURSES (CourseNo, CourseName, TeacherID)

Page 32: MIS 111:  Computers and the inter-networked society

WHAT THIS WOULD ACTUALLY LOOK LIKE AS RELATIONAL TABLES “TeacherID” is now a foreign key in the

COURSES table.

CourseNo CourseName TeacherIDMIS111 CMP_INTRNTWK

D23489

MIS373 SYSTM_ANL_DSGN

13445

MIS696A RDNGS_IN_MIS NULL

TeacherID TeacherName

TeacherEmail

TeacherSalary

13445 Killinger [email protected] Class_C

23489 Carl [email protected] Class_D

Page 33: MIS 111:  Computers and the inter-networked society

STEPS TO CONVERT AN ERD TO A SET OF RELATIONAL TABLES 3. Locate any many-to-many

relationships. Create a completely new table to represent this relationship. Use the primary keys of the participating entity classes as a new combined primary key. We now have THREE tables instead of two.

COURSES (CourseNo, CourseName, TeacherID)

STUDENTS (StudentID, StudentName, StudentEmail)

STUDENTS_COURSES (StudentID, CourseID)

Page 34: MIS 111:  Computers and the inter-networked society

WHAT THIS WOULD ACTUALLY LOOK LIKE AS RELATIONAL TABLES

CourseNo CourseName TeacherIDMIS111 CMP_INTRNTWK

D23489

MIS373 SYSTM_ANL_DSGN

13445

MIS696A RDNGS_IN_MIS NULLTeacherID TeacherName

TeacherEmail

TeacherSalary

13445 Killinger [email protected] Class_C23489 Carl [email protected]

uClass_D

StudentID StudentName StudentEmail112923049 Smith [email protected] Jones [email protected]

StudentID CourseNo112923049 MIS111112923049 MIS373490234098 MIS111

Page 35: MIS 111:  Computers and the inter-networked society

OUR FINAL SET OF RELATIONS

STUDENTS (StudentID, StudentName, StudentEmail)

TEACHERS (TeacherID, TeacherName, TeacherEmail)

COURSES (CourseNo, CourseName, TeacherID)

STUDENTS_COURSES (StudentID, CourseNo)

Page 36: MIS 111:  Computers and the inter-networked society

ANOTHER EXAMPLE: YOU TRY

PUPPIES STORES

CUSTOMERS

buy

sell

StoreID

StoreName StoreLoc

PupAgeWhenSold

PupBreed

PupTempPupID

CustZip

CustName

CustGender

CustID

[1:1]

[1:M]

[0:1]

[1:M]

Page 37: MIS 111:  Computers and the inter-networked society

LET’S CONVERT THIS ERD TO A SET OF RELATIONAL TABLES 1. For every strong entity class, create a table

or relation.

2. Locate any [1:M] relationships between strong entity classes. Put the primary key on the “1” side of the relationship into the table of the “M” side.

3 . Locate any [M:N] relationships. Create a completely new table to represent this relationship. Use the primary keys of the participating entity classes as a new combined primary key.

Page 38: MIS 111:  Computers and the inter-networked society

PRETTIEST PUPPIES & CO SET OF RELATIONS PUPPIES (PupID, PupBreed, PupTemp,

PupAgeWhenSold, StoreID, CustID)

STORES (StoreID, StoreName, StoreLoc)

CUSTOMERS (CustID, CustName, CustGender, CustZip)

Page 39: MIS 111:  Computers and the inter-networked society

WHAT THIS WOULD ACTUALLY LOOK LIKES AS RELATIONAL TABLES

StoreID StoreName StoreLoc1 Puppies ‘R’ US Tucson4 Pup Place Phoenix

CustID CustName CustGender

CustZip

2 Xavier M 6047710 Martha F 2230312 Bill M 85719

PupID

PupBreed

PupTemp

PupAgeWhenSold

StoreID

CustID

3 dalmatian

active 8 4 12

4 beagle sweet 10 1 27 laborador sweet 7 4 128 shih-tzu active 8 4 10

Page 40: MIS 111:  Computers and the inter-networked society

TWO MORE THINGS: WEAK ENTITY CLASSES AND ONE-TO-ONE RELATIONSHIPS

INSTRUCTORS MUSICIANSteach

LESSONS

MusIDMusNam

e

MusEmail

InsID

InsEmailInsName

TimeDay

[0:M]

[1:1]

[1:1]MusInst

Page 41: MIS 111:  Computers and the inter-networked society

STEPS TO CONVERT ERD TO SETS OF RELATIONAL TABLES 4. Locate any one-to-one relationships

between entity classes. Take the primary key from one side of the relationship and place it in the table of the other entity class.

INSTRUCTORS (InsID, InsName, InsEmail, MusID)

MUSICIANS (MusID, MusName, MusEmail, MusInst)

INSTRUCTORS (InsID, InsName, InsEmail)

MUSICIANS (MusID, MusName, MusEmail, MusInst, InsID)

OR

Page 42: MIS 111:  Computers and the inter-networked society

STEPS TO CONVERT ERD TO SETS OF RELATIONAL TABLES 5.For weak entity classes, create a new

table or relation and add its attributes. Then, add the primary key from its corresponding strong entity class. Combine all attributes to create a new primary key.

LESSONS (Day, Time, MusID, InsID)

Page 43: MIS 111:  Computers and the inter-networked society

YOU TRY: DOCTORS, PATIENTS, AND TREATMENTS Convert this ERD into a set of relational

tables.

DOCTORS PATIENTS

TREATMENTS

treat

[1:1]

[1:1]

[0:M]

DocID

DocNamePatName

PatID

PrscrptDate

Page 44: MIS 111:  Computers and the inter-networked society

EXAMPLE: DOCTORS, PATIENTS, AND TREATMENTS 5.For weak entity classes, create a new

table or relation and add its attributes. Then, add the primary key from its corresponding strong entity class. Combine all attributes to create a new primary key.

DOCTORS (DocID, DocName)

PATIENTS (PatID, PatName, DocID)

TREATMENTS (Date, Prscrpt, PatID, DocID)

Page 45: MIS 111:  Computers and the inter-networked society

AGGREGATES: TEAMS 6. Treat aggregates just like strong

entity classes. Create a table or relation. The identifier becomes what is called a

primary key.The other attributes become what are

called non-key elements.

7. Treat the aggregation as its own relationship and add foreign keys accordingly.

Page 46: MIS 111:  Computers and the inter-networked society

AGGREGATES: TEAMS

TEAMS

Aggregate

STUDENTS

TEACHERS

[2:5]

[1:1]

[0:M]

[1:3]

TEAMS (TeamID, TeamCaptain, FormationDate, TeacherID)

TEAMS_STUDENTS (StudentID, TeamID)

Page 47: MIS 111:  Computers and the inter-networked society

PHEW. EVERYBODY OKAY? Quiz

Tomorrow: I will give you / post your assignment

Paper or Visio (preferred). Stencils are on the Web site

You’ll have the rest of the class time to work on it (individual assignment). This will be due beginning of class next Wednesday.

I will be able to answer “general” questions.