CS 157B: Database Management Systems II January 23 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.

Slides:



Advertisements
Similar presentations
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Advertisements

Chapter Information Systems Database Management.
CS 185C/286: The History of Computing October 31 Class Meeting Department of Computer Science San Jose State University Fall 2011 Instructor: Ron Mak
3-1 Chapter 3 Data and Knowledge Management
CS 235: User Interface Design January 22 Class Meeting
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Chapter 5 Database Processing.
Database Design Concepts
Information storage: Introduction of database 10/7/2004 Xiangming Mu.
CS 160: Software Engineering November 10 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
CS 153: Concepts of Compiler Design August 24 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 157B: Database Management Systems II May 8 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak
CS 160: Software Engineering October 8 Class Meeting
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Introduction to SQL Steve Perry
CS 157B: Database Management Systems II January 30 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Introduction to Database Systems
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
CS 174: Web Programming September 23 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 174: Web Programming September 21 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 157B: Database Management Systems II February 6 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
Information Systems Today (©2006 Prentice Hall) 3-1 CS3754 Class Note 12 Summery of Relational Database.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
Lecturer: Gareth Jones. How does a relational database organise data? What are the principles of a database management system? What are the principal.
CS 157B: Database Management Systems II February 4 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
CS 157B: Database Management Systems II January 28 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
CS 160: Software Engineering October 1 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
CS 160: Software Engineering October 15 Class Meeting
CS 160: Software Engineering October 6 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
CS 153: Concepts of Compiler Design August 26 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
CS 174: Web Programming October 14 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
Data modeling Process. Copyright © CIST 2 Definition What is data modeling? –Identify the real world data that must be stored on the database –Design.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
CS 174: Web Programming November 2 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Howard Paul. Sequential Access Index Files and Data File Random Access.
CS 157B: Database Management Systems II April 22 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak.
CS 160 and CMPE/SE 131 Software Engineering March 10 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant EPS
CS 160 and CMPE/SE 131 Software Engineering March 15 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
Introduction to Database Programming with Python Gary Stewart
Decision Analysis Fall Term 2015 Marymount University School of Business Administration Professor Suydam Week 10 Access Basics – Tutorial B; Introduction.
CS 153: Concepts of Compiler Design August 29 Class Meeting
Chapter 12 Information Systems.
Entity-Relationship Modeling
Information Systems Database Management
CMPE 152: Compiler Design January 25 Class Meeting
Databases and Information Management
CS 174: Server-Side Web Programming February 12 Class Meeting
CMPE 152: Compiler Design August 21 Class Meeting
Databases and Information Management
CMPE 152: Compiler Design January 24 Class Meeting
CMPE/SE 131 Software Engineering March 9 Class Meeting
A Very Brief Introduction to Relational Databases
CMPE/SE 131 Software Engineering March 7 Class Meeting
Presentation transcript:

CS 157B: Database Management Systems II January 23 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 2 CS 157B / SE 157B  Database Management Systems II A survey course A deep course Instructor: Ron Mak Class website: Section 1: MW 3:00 – 4:15 PM in MH 222 Section 2: MW 6:00 – 7:15 PM in MH 222

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 3 CS 157B / SE 157B  Both sections are currently full. If you want to try get onto the class, pick up an Add Form from me, fill it out, and return it at the end of this class. I will put you on the waiting list of your desired section and send you an add code whenever an opening occurs. Graduating seniors have highest priority on the waiting list.

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 4 Rough Semester Outline WeekTopic 1-3Object-relational mapping (ORM) 4-5Extensible Markup Language (XML) 6-7Web services Midterm #1 (Wednesday, March 6) 8-9Data warehousing Spring recess 10-11Data warehousing, continued Midterm #2 (Monday, April 15) 12-14Data virtualization 15-16Content management Sec.Final exam 1Thurs, May 16 12:15-2:30 PM MH 222 2Wed, May 15 5:15-7:30 pm PM MH 222

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 5 Form Project Teams  3 students each. Pick a team name.  Each team member will get the same score for each team project.  Teams will last the entire semester. Choose your team members wisely!  Someone from each team send me: Your team name Name and address of each team member _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 6 Projects  One- or two-week projects Topics: ORM, XML, web services  Three- or four-week projects Topics: data warehousing, data virtualization  Each project involves: Research on the topic. A working application that uses the topic’s technology. A short report that describes the application, how it uses the technology, and how to run it.  Each project is worth a maximum of 100 points. Each team member gets the same score. Late projects lose 20 points plus an additional 20 points for each 24 hours after the due date.

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 7 Oral Presentations  Each team will have at least one opportunity during the semester to give an oral presentation in front of the class. Describe a project application. Do a demo. _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 8 Postmortem Reports  At the end of the semester, each student will individually turn in a short (a few paragraphs) private individual postmortem report that includes: A brief description of what you learned in the course. An assessment of your accomplishments for your team on the projects. An assessment of each of your other project team members. _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 9 Grading  Weights 65% projects* 10% midterm #1** 10% midterm #2** 15% final**  Each project and exam will be scored but not given a letter grade.  Final individual class letter grades will be based on the class curve. Adjustments up or down depending on the level and quality of your participation and by your team members’ assessments of your performance. *team scores **individual scores

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 10 Take roll

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 11 Data Independence  Goal: Loose coupling between applications and the data repository. Manage complexity. Manage change.  Applications should not need to know: Where the data is stored (location of the repository). How it is stored (file formats and organizations, etc.). Access mechanisms. _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 12 Data Modeling  A data model is a diagram that shows what data an application works with and how the data is used. Model data that will be persisted (written to and read from a data repository).  For databases, objects are called entities. Model entities and their relationships to each other. _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 13 Data Modeling  Conceptual data model A high-level user-oriented description of the data.  entities  relationships among the entities  who will use the data (access control)  how it will be used (use cases)  Logical data model A diagram showing names, attributes, keys, and relations.  Physical data model A configuration specification or a script to build the repository. Used by repository developers and maintainers.

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 14 Conceptual Data Model Example  Student, teacher, and class entities and their attributes. Student  id  name  contact information  which classes taken Teacher  id  name  contact information  which classes taught Class  class code  subject name  class room number

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 15 Conceptual Data Model Example  Sample queries What teachers does this student have? What classes does this teacher teach? Who is the teacher of this class? Which students are in this class? Which students are taught by this teacher?  These queries suggest there are binary relationships (associations) between entities!

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 16 The Relational Data Model  Data element: a value that is stored in the repository (i.e., the database). Values are typed. A value can be null.  Entity: a group of data elements that together are meaningful for a person or an application. Similar to objects. Each data element is the value of an attribute of the entity. _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 17 The Relational Data Model  Table: a conceptual two-dimensional structure that contains entities of a particular type. Also called a relation. Each row (also called a record) contains the attribute values of one entity. Each column (also called a field) holds an attribute value. table  relation row  entity rows and columns  records and fields attribute value  data element

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 18 Logical Data Model  Initial version IdNameClass_codeSubjectRoom 7003Rogers, Tom926Java programming Thompson, Art908Data structures Lane, John951Software engineering Lane, John974Operating systems Flynn, Mabel931Compilers222 John Lane teaches two classes. Each table has a primary key (PK) field whose value in each record uniquely identifies that record. IdNameTeacher_id_1Teacher_id_2Teacher_id_3 1001Doe, John Novak, Tim null 1009Klein, Leslienull 1014Jane, Mary7051null 1021Smith, Kim Student Teacher  Student id name which teachers  Teacher id name which classes taught  Class class code subject name class room number PK

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 19 Normalization  Relational tables need to be normalized. Improve the stability of the model.  More resilient to change. Faster record insertions and updates. Improve data quality.  There are six normal forms, but we will only consider the first two. Each normal form includes the lower normal forms.  Example: A database in second normal form is also in first normal form.

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 20 First Normal Form (1NF)  Separate multi-valued data elements. Break the name fields into last name and first name fields. IdLastFirstTeacher_id_1Teacher_id_2Teacher_id_3 1001DoeJohn NovakTim null 1009KleinLeslienull 1014JaneMary7051null 1021SmithKim IdLastFirstClass_codeSubjectRoom 7003RogersTom926Java programming ThompsonArt908Data structures LaneJohn951Software engineering LaneJohn974Operating systems FlynnMabel931Compilers222 Student Teacher IdNameTeacher_id_1Teacher_id_2Teacher_id_3 1001Doe, John Novak, Tim null 1009Klein, Leslienull 1014Jane, Mary7051null 1021Smith, Kim IdNameClass_codeSubjectRoom 7003Rogers, Tom926Java programming Thompson, Art908Data structures Lane, John951Software engineering Lane, John974Operating systems Flynn, Mabel931Compilers222

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 21 First Normal Form  Move repeating data elements to a new table. IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim Student_idTeacher_id Join table IdLastFirstClass_codeSubjectRoom 7003RogersTom926Java programming ThompsonArt908Data structures LaneJohn951Software engineering LaneJohn974Operating systems FlynnMabel931Compilers222 Student Teacher Student_Teacher IdLastFirstTeacher_id_1Teacher_id_2Teacher_id_3 1001DoeJohn NovakTim null 1009KleinLeslienull 1014JaneMary7051null 1021SmithKim

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 22 Problem!  Suppose Prof. Lane decides he doesn’t want to teach Operating Systems anymore and we delete that row.  What other information do we lose as a result? We lose the fact that the class is taught in Room 109.  The problem arises because the Teacher table really contains two separate sets of data: teacher data and class data. IdLastFirstClass_codeSubjectRoom 7003RogersTom926Java programming ThompsonArt908Data structures LaneJohn951Software engineering LaneJohn974Operating systems FlynnMabel931Compilers222 Teacher

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 23 Second Normal Form  Keep related data together (cohesiveness). IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel Class_codeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 TeacherClass Primary key (PK) Foreign key (FK) IdLastFirstClass_codeSubjectRoom 7003RogersTom926Java programming ThompsonArt908Data structures LaneJohn951Software engineering LaneJohn974Operating systems FlynnMabel931Compilers222 Teacher

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 24 Final Database Structure IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel Teacher Student Class Student_Class  John Doe takes Java programming, software engineering, and data structures.  The Java Programming class has John Doe and Kim Smith.  Mabel Flynn teaches compilers.

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 25 Entity-Relationship (ER) Diagrams  Entity-Relationship (ER) diagrams are logical data modeling diagrams. Very similar in concept to UML diagrams. There are several styles of ER diagrams.  We’ll use crow’s feet diagrams.  We’ll use a tool to generate these diagrams. _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 26 One-to-One Relationship  One (each) teacher has one contact information. IdLastFirstContact_id 7003RogersTom ThompsonArt LaneJohn FlynnMabel856 Id _address TeacherContact_Info one

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 27 One-to-Many Relationship  One (each) teacher teaches 0, 1, or many classes. IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 TeacherClass onezeroonemany Database cardinality is only 0, 1, or many (more than 1).

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 28 Many-to-Many Relationship IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code Student Class Student_Class  A student has 0, 1 or many classes.  A class has 1 or many students. Class Student Student-Class

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 29 Complete Entity Diagram code (PK) teacher_id (FK) subject room Class CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Class

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 30 SQL  Structured Query Language (SQL) An industry standard But has many proprietary extensions  Language for managing data in a relational database. Create and drop (delete) databases Create, alter, and drop tables of a database Retrieve, insert, update, and delete data in the tables. _

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 31 SQL Query Examples  What is the class code of the Java programming class? CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Class SELECT code FROM class WHERE subject = 'Java programming' | code | | 926 | Source tablesDesired attributes Selection criteria

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 32 SQL Query Examples  Who teaches Java programming? IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 ClassTeacher SELECT first, last FROM teacher, class WHERE id = teacher_id AND subject = 'Java programming' | first | last | | Tom | Rogers | Selecting from multiple tables is called a join.

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 33 SQL Query Examples  What classes does John Lane teach? SELECT code, subject FROM teacher, class WHERE last = 'Lane' AND first = 'John' AND id = teacher_id | code | subject | | 951 | Software engineering | | 974 | Operating systems | IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 ClassTeacher

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 34 SQL Query Examples  Who takes Java programming? IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code SELECT id, last, first FROM student, class, student_class WHERE subject = 'Java programming' AND code = class_code AND id = student_id | id | last | first | | 1001 | Doe | John | | 1021 | Smith | Kim | Class Student_Class Student

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 35 SQL Query Examples  What classes does John Doe take? IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code SELECT code, subject FROM student, class, student_class WHERE last = 'Doe' AND first = 'John' AND id = student_id AND code = class_code | code | subject | | 908 | Data structures | | 926 | Java programming | | 951 | Software engineering | ClassStudent Student_Class

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 36 SQL Query Examples  Who are John Lane’s students? IdLastFirst 1001DoeJohn 1005NovakTim 1009KleinLeslie 1014JaneMary 1021SmithKim CodeTeacher_idSubjectRoom Data structures Java programming Compilers Software engineering Operating systems109 Student_idClass_code SELECT student.first, student.last, subject FROM student, teacher, class, student_class WHERE teacher.last = 'Lane' AND teacher.first = 'John' AND teacher_id = teacher.id AND code = class_code AND student.id = student_id ORDER BY subject, student.last | first | last | subject | | Tim | Novak | Operating systems | | Kim | Smith | Operating systems | | John | Doe | Software engineering | IdLastFirst 7003RogersTom 7008ThompsonArt 7012LaneJohn 7051FlynnMabel Teacher StudentClass Student_Class

Department of Computer Science Spring 2013: January 23 CS 157B: Database Management Systems II © R. Mak 37 MySQL  Popular open-source relational database management system (RDBMS). The M in LAMP (Linux+Apache+MySQL+PHP)  or Perl or Python Now part of Oracle. Download from