CS370 Spring 2007 CS 370 Database Systems Lecture 6 Introduction to Database Design.

Slides:



Advertisements
Similar presentations
Chapter 2: Entity-Relationship Model
Advertisements

Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Temple University – CIS Dept. CIS616– Principles of Database Systems
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Huiswerk Lees delen 3.2, 3.3 van hoofdstuk 3. opgaven voor hoofdstuk 2: modelleeropgave 5.
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
Department of Computer Science, HKUST 1
Text-Book Chapters (7 and 8) Entity-Relationship Model
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CS157A Lecture 3 ER Diagram Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Chapter 3: Relational Model
1 Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Chapter 2: Entity-Relationship Model (Continued)
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
©Silberschatz, Korth and Sudarshan1.1Database System Concepts Wat gaan wij leren? Data Bases Data modelleren  Hoe kan ik zien wat voor informatiesysteem.
Entity-Relationship Model
CS 405G Introduction to Database Systems
Data Modeling Using the Entity-Relationship Model
the Entity-Relationship Model
ICOM 5016 – Introduction to Database Systems Lecture 4 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
FEN  Conceptual modelling: The Entity-Relation (ER) Model Conceptual models Entity – Relation (ER) models.
Database System Concepts, 5th Ed. Chapter 6: Entity-Relationship Model.
Entity-Relationship Model
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
FEN Introduction to the database field:  Conceptual modelling: The Entity-Relation (ER) Model Seminar: Introduction to relational databases.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 7 Database Design and The E–R Model. 2 Goals n Facilitate DB design and represent the overall logical structure of the DB. n Definition Entities.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan Chapter 6: Entity-Relationship Model.
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
1 Session 2 Welcome: The seventh learning sequence “ Reduction of an EER schema to tables“ Recap : In the previous learning sequence, we discussed the.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Computing & Information Sciences Kansas State University Wednesday, 24 Sep 2008CIS 560: Database System Concepts Lecture 12 of 42 Wednesday, 24 September.
CS 405G: Introduction to Database Systems Lecture 2 : Database Design I.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Entity Relationship Diagram (2)
ITTelkom Entity Relationship Diagram (1) CS2343 Perancangan Basisdata Relasional.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
ICOM 5016 – Introduction to Database Systems Lecture 5 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 3 Data Modeling Using Entity-Relationship Model.
Data Modeling Using the Entity-Relationship (ER) Data Model.
Chapter 3: Data Modeling Using the Entity-Relationship (ER) Data Model
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CS157A Lecture 4 ER Model 2 Prof. Sin-Min Lee Department of Computer Science San Jose State University.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts - 6 th Edition Chapter 7: Entity-Relationship Model.
Conceptual Modelling The Entity-Relationship (ER) Model The ER diagram Data Modelling.
Lecture 26 Enterprise Systems Development ( CSC447 ) COMSATS Islamabad Muhammad Usman, Assistant Professor.
Topic 3: ER – Entity Relationship Model (ERM) 6/12/
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Chapter 2: Entity-Relationship Model
Comp 1100 Entity-Relationship (ER) Model
Entity-Relationship Model
Entity Relationship Model
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Session 2 Welcome: The seventh learning sequence
Initial Design of Entity Types: EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT Gender.
Chapter 6: Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Presentation transcript:

CS370 Spring 2007 CS 370 Database Systems Lecture 6 Introduction to Database Design

CS370 Spring 2007 A case Study A primary school student writes a composition about a picnic: Today is Sep 9, the weather is fine. My classmates, Ali, Maria and I go to a picnic in park. Our teacher is Mr. Khan Picnic weather destination date Students Name Teacher Name My Initial Design:

CS370 Spring 2007 Questions ? Why “Ali”, “Maria”, “Mr. Khan” are not in the ER diagram ? What do these names tell us ? What are the keys of Student, Picnic & Teacher ? What are the cardinalities of the relationships ?

CS370 Spring 2007 Every student has an ID number, it is better to keep it in the database and use it as a key I bet that there won’t be teachers with the same name; otherwise, I’ll add employee number and use it as a key goes is N:M, why ? A picnic has more than one student participating; also, a student can go to more than 1 picnic. However, this N:M relationship allows a student to go to more than one picnic on the same date leading is N:1, why? Depends on your assumptions –I assume a teacher can only lead 1 picnic on a certain date, so given the teacher name and the date, I can identify a picnic Picnic is made a weak entity. I could have added a PicnicNo, but it would be very awkward. My solution Student StudentNo Nameweather date destination Picnic goes leading Teacher Name

CS370 Spring 2007 E-R Design Decisions The use of an attribute or entity set to represent an object. –Should an address be an attribute or entity? Whether a real-world concept is best expressed by an entity set or a relation set. –Should marriage be an entity or relationship? –Should picnic be an entity or relationship? The use of a ternary relationship versus a pair of binary relationships. –See the borrow-loan-branch example The use of a strong or weak entity set. –See the employee-dependent example

CS370 Spring 2007 E-R Diagram for Company Database EMPLOYEE WORKS_FOR MANAGES CONTROLS Startdate DEPARTMENT WORKS_ON PROJECT Hours DEPENDENTS_OF DEPENDENT SUPERVISION supervisee supervisor FnameMinitLname Name Sex Address Salary Ssn Bdate Number Of Employees Name Number Locations Name Number Location RelationshipBirthdateSexName Can you translate it back into English?

CS370 Spring 2007 Consider representing Part-time and Full-time employees in the company database: –Either you have two entity types will lots of similarity –Or you have a single entity type with redundancy for most of the entities within it ER model is extended to support other features such as generalization (but it won’t be covered in this course!) Limitations of ER model

CS370 Spring 2007 Reduction of an E-R Schema to tables Primary keys allow entity sets and relationship sets to be expressed uniformly as tables which represent the contents of the database. A database which conforms to an E-R diagram can be represented by a collection of tables. Always! Converting an E-R diagram to a table format is the basis for deriving a relational database design from an E-R diagram.

CS370 Spring 2007 Composite key Representing Entity Sets as Tables A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set A strong/regular entity set reduces to a table with the same attributes. payment loan-no payment-datepayment-nopayment-amount L-17 L-15 L May May May customer customer-name customer-streetcustomer-id Jones Hayes Smith Main North customer-city Harrison Rye Harrison

CS370 Spring 2007 Representing Relationship Sets as Tables depositor A many-to-many relationship set is represented as table with columns for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set. customer depositor loan loan-no cust-no share% date cust-name

CS370 Spring For 1:N and 1:1 relationships, you can create a table for each relationship +But it is more concise to merge the relationship-table with the entity-table on the “N” side customer cust-no cust-name A12345 B56789 Peter Wong Mary Cheung loan loan-no L-001 L-002 date Sep 2000 Aug 2001 customer borrow loan cust-no cust-name date loan-no cust-no A12345 B56789 indicates who borrowed the loan

CS370 Spring In a 1:N relationship, can we include the key from the “N” side in the table representing the entity in the “1” side? I.e., include Loan_no into the Customer table. Why and Why not? Questions to Think About +How can we express existence constraints on table?

CS370 Spring 2007 Questions to Think About (Cont.) +In a 1:1 relationship, we can include the key from either entity into the table representing the other entity. Suppose the Loan-Customer relationship is 1:1, would you include the Customer_no into Loan or Loan_no into Customer? customer borrow loan cust-no cust-name date loan-no loan loan-no L-001 L-002 date Sep 2000 Aug 2001 cust-no A12345 B56789 customer cust-no cust-name A12345 B56789 Peter Wong Mary Cheung loan-no L-001 L-002 Which one is better?

CS370 Spring 2007 Questions to Think About (Cont.) +How can we express existence constraints on table? customer borrow loan cust-no cust-name date loan-no loan loan-no L-001 L-002 date Sep 2000 Aug 2001 cust-no A12345 Not allowed; must be enforced by DBMS

CS370 Spring 2007 Weak Entities +Since a weak entity has to include the primary key of the identifying entity, the 1:N relationship is already captured. E.g., The payment table already contains information about the Loan (I.e., loan_no) Already indicates the 1:N relationship between loan-no and payment-no payment loan-no payment-datepayment-nopayment-amount L May May May

CS370 Spring 2007 Summary of Symbols Used in E-R Notation

CS370 Spring 2007 Summary of Symbols Used in E-R Notation

CS370 Spring 2007 E-R Diagram for a Banking Enterprise

CS370 Spring 2007 E-R Diagram for Exercise 2.12 E-R Diagram for a Publisher Enterprise