COMP 430 Intro. to Database Systems Entity-Relationship Diagram Basics Slides use ideas from Chris Ré.

Slides:



Advertisements
Similar presentations
ER Modeling Case Studies
Advertisements

Exercise 1 Consider the ER diagram below. Assume that an employee may work in up to two departments or may not be assigned to any department. Assume that.
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Data Modeling. What are you keeping track of? You begin to develop a database by deciding what you are going to keep track of. Each thing that you are.
ER Modeling Case Studies
COMP 3715 Spring 05. Working with data in a DBMS Any database system must allow user to  Define data Relations Attributes Constraints  Manipulate data.
Chapter 31 Chapter 3 Data Modeling Using the Entity-Relationship Model.
Information Systems Chapter 4 Relational Databases Modelling.
ENTITY RELATIONSHIP MODELLING
1 Lecture 04 Entity/Relationship Modelling. 2 Outline E/R model (Chapter 5) From E/R diagrams to relational schemas (Chapter 5) Constraints in SQL (Chapter.
Lecture #2 October 5 th, 2000 Conceptual Modeling Administration: –HW1 available –Details on projects –Exam date –XML comment.
Data modelling uses two main techniques Entity relationship (E-R) modelling: a top- down approach Normalisation: a bottom-up approach.
Sunday, June 28, Entity-Relationship and Enhanced Entity-Relationship Conceptual Data Models (Chapters 6 & Section 7.1)
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
8/28/97Information Organization and Retrieval Database Design University of California, Berkeley School of Information Management and Systems SIMS 202:
Case study Lisa’s Bookstore IST210.
Lecture 9: Conceptual Database Design January 27 th, 2003.
Functional Dependencies and Relational Schema Design.
Entity/Relationship Modelling
The Relational Data Model Database Model (ODL, E/R) Relational Schema Physical storage ODL definitions Diagrams (E/R) Tables: row names: attributes rows:
CS411 Database Systems Kazuhiro Minami
ER Modeling Case Studies
Database Design April 3, Projects, More Details Goal: build a DB application. (almost) anything goes. Groups of 3-4. End of week 2: groups formed.
the Entity-Relationship Model
Entity Relationship Modelling. What is Entity Relationship Modelling? The Entity-Relationship model is – ” “ a data model for high-level descriptions.
Entity / Relationship Diagrams Objects entities Classes entity sets Attributes are like in ODL. Relationships: like in ODL except - not associated with.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
E/R Diagrams and Functional Dependencies. Modeling Subclasses The world is inherently hierarchical. Some entities are special cases of others We need.
Lecture 08: E/R Diagrams and Functional Dependencies.
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
Conceptual Database Design. Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the.
1 Introduction to Database Systems CSE 444 Lecture 07 E/R Diagrams October 10, 2007.
1 The Information School of the University of Washington Dec 1fit advdatabases © 2006 University of Washington Advanced Database Concepts INFO/CSE.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
Database Design Why do we need it? – Agree on structure of the database before deciding on a particular implementation. Consider issues such as: –What.
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
COMP 430 Intro. to Database Systems Multi-table SQL Slides use ideas from Chris Ré and Chris Jermaine. Get clickers today!
1 Lecture 08: E/R Diagrams and Functional Dependencies Friday, January 21, 2005.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
COMP 430 Intro. to Database Systems ER Implementation as Tables Slides use ideas from Chris Ré.
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
COMP 430 Intro. to Database Systems ER Design Considerations Slides use ideas from Chris Ré.
Data Modeling AND ER MODELS.
Year 12 > 13 Applied GCE ICT Unit 7 Using Database Software.
Lecture 4: The E/R Model Lecture 4 Today’s Lecture 1.E/R Basics: Entities & Relations ACTIVITY: Crayon time! 2.E/R Design considerations ACTIVITY: Crayon.
Entity/Relationship Modelling
Lecture 5: Conceptual Database Design
Entity Relationship Model
COP5725 Database Management ER DIAGRAM AND RELATIONAL DATA MODEL
Database Design Oct. 3, 2001.
Database Design Why do we need it? Consider issues such as:
Database Management Systems (CS 564)
Lecture 4 Lecture 4: The E/R Model.
Conceptual Database Design
ER MODEL Lecture 3.
COMP 430 Intro. to Database Systems
Cse 344 May 11th – Entities.
Entity – Relationship Model
Functional Dependencies
CMPT 354: Database System I
Lecture 8: The E/R Model I
Lecture 9: The E/R Model II
Functional Dependencies
Functional Dependencies
Lecture 06: SQL Monday, October 11, 2004.
Presentation transcript:

COMP 430 Intro. to Database Systems Entity-Relationship Diagram Basics Slides use ideas from Chris Ré.

Goal: Agree on DB structure to implement. What entities to model How entities related What constraints exist in domain How to achieve good design

(Logical) Entity-Relationship Diagrams Makes Product name category price Company name Precise enough for technical decisions Abstracted enough to omit some implementation details Abstracted enough for non-technical people “The Entity-Relationship model – toward a unified view of data” Peter Chen, 1976

Makes Product name category price Company name Entity sets – classes/types of objects Attributes of entity sets Entities – individual objects Relationship – between entity sets Primary key – minimal set of attributes that uniquely identifies entity

Makes Buys Employs Product namecategory price Person address namessn Company stockprice name

Mathematical definitions a b c d AB Sets A, B: A={1,2,3}, B={a,b,c,d}

Mathematical definitions Sets A, B: A={1,2,3}, B={a,b,c,d} Cross-product A  B: The set of all (a,b) pairs A  B = {(1,a), (1,b), (1,c), (1,d), (2,a), (2,b), (2,c), (2,d), (3,a), (3,b), (3,c), (3,d)} a b c d AB

Mathematical definitions Sets A, B: A={1,2,3}, B={a,b,c,d} Cross-product A  B: The set of all (a,b) pairs A  B = {(1,a), (1,b), (1,c), (1,d), (2,a), (2,b), (2,c), (2,d), (3,a), (3,b), (3,c), (3,d)} Relationship R: A subset of A  B R = {(1,a), (2,c), (2,d), (3,b)} a b c d AB

Makes Product name category price Company name Product and Company are sets of entities. Entities uniquely identified by primary keys. Makes is a relationship – a subset of Product  Company. Tuples uniquely identified by pairs of Product & Company’s keys.

Product namepricecategory Gizmo19.99Electronics Powergizmo39.99Electronics Gadget19.99Toys name GizmoWorks GadgetCorp Company Product p × Company c p.namep.pricec.categoryc.name Gizmo19.99ElectronicsGizmoWorks Powergizmo39.99ElectronicsGizmoWorks Gadget19.99ToysGizmoWorks Gizmo19.99ElectronicsGadgetCorp Powergizmo39.99ElectronicsGadgetCorp Gadget19.99ToysGadgetCorp Makes Product name category price Company name

Product namepricecategory Gizmo19.99Electronics Powergizmo39.99Electronics Gadget19.99Toys name GizmoWorks GadgetCorp Company Product p × Company c p.namep.pricec.categoryc.name Gizmo19.99ElectronicsGizmoWorks Powergizmo39.99ElectronicsGizmoWorks Gadget19.99ToysGizmoWorks Gizmo19.99ElectronicsGadgetCorp Powergizmo39.99ElectronicsGadgetCorp Gadget19.99ToysGadgetCorp Makes Product name category price Company name Makes p.namep.pricec.categoryc.name Gizmo19.99ElectronicsGizmoWorks Powergizmo39.99ElectronicsGizmoWorks Gadget19.99ToysGadgetCorp

Can have multiple relationships between same entity sets. Each is a subset of Person  Company with primary key (ssn, name). WorksFor PersonCompany OwnsStock Likes addressname ssn stockprice name

Can have relationship between single entity set. A subset of Person  Person with primary key (ssn, ssn). Friend Person addressname ssn

Relationships can have attributes Product name category price Company name Makes since Relationship attributes are implicitly unique per (p.name, c.name).

Relationship vs. entity Product name category price Person p_id Purchased date Relationship attributes are implicitly unique per (name, p_id). What if we don’t want uniqueness?

Relationship vs. entity Product name category price Person p_id date Purchase quantitypurch_id ProductOfBuyerOf Representing as an entity allows multiple Purchases for each Product-Person combination.

Activity – Draw ER diagram Authors have IDs and names. They write books. Books have ISBNs and titles. The library keeps track of how many copies it has of the book. Each book is written by authors and published by a publisher. We want to know every time it is checked out by a borrower. Borrowers have a library card number, name, and address. They can check out a book on a particular date. Publishers have an ID, name and address. They publish books.