mis 111: computers and the inter-networked society
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 PresentationTRANSCRIPT
MIS 111: COMPUTERS AND
THE INTER-NETWORKED
SOCIETYClass 9: Database Management
SystemsJuly 21st, 2011
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.
ADMINISTRATION Visio stencil on my Web site for ER
diagrams
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
ER DIAGRAM RECAP
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.
INSTRUCTORS Musiciansteach
LESSONS
MusIDMusNam
e
MusEmail
InsID
InsEmailInsName
TimeDay
[0:M]
[1:1]
[1:1]
TWINKLE TONES PRIVATE LESSONS
TEAMS
Aggregate
STUDENTS
TEACHERS
[2:5][1:1]
[0:M]
[1:3]
AGGREGATE CLASSES REVISITED
TeamIdTeamNam
e
StudentId
Name
TeacherId
RELATIONAL TABLES
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.
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
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
THE HIERARCHICAL MODEL
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
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/
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/
CODD’S NORMAL FORMS (RULES) 3rd normal form (Rule 3)
No dependencies on non-key attributes
Take from http://www.phlonx.com/resources/nf3/
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!!!
REVIEW SOME TERMINOLOGY
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]
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]
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]
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]
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)
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)
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)
WHAT WE HAVE SO FAR TEACHERS (TeacherID, TeacherName,
TeacherEmail, TeacherSalary)
STUDENTS (StudentID, StudentName, StudentEmail)
COURSES (CourseNo, CourseName)
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
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]
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)
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
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)
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
OUR FINAL SET OF RELATIONS
STUDENTS (StudentID, StudentName, StudentEmail)
TEACHERS (TeacherID, TeacherName, TeacherEmail)
COURSES (CourseNo, CourseName, TeacherID)
STUDENTS_COURSES (StudentID, CourseNo)
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]
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.
PRETTIEST PUPPIES & CO SET OF RELATIONS PUPPIES (PupID, PupBreed, PupTemp,
PupAgeWhenSold, StoreID, CustID)
STORES (StoreID, StoreName, StoreLoc)
CUSTOMERS (CustID, CustName, CustGender, CustZip)
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
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
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
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)
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
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)
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.
AGGREGATES: TEAMS
TEAMS
Aggregate
STUDENTS
TEACHERS
[2:5]
[1:1]
[0:M]
[1:3]
TEAMS (TeamID, TeamCaptain, FormationDate, TeacherID)
TEAMS_STUDENTS (StudentID, TeamID)
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.