Lecture 2: Entity/Relationship modelling

Slides:



Advertisements
Similar presentations
Conceptual Design using the Entity-Relationship Model
Advertisements

Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
1 541: Database Systems S. Muthu Muthukrishnan. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.)  What are the entities.
The Entity-Relationship (ER) Model
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
Comp3300/fall021 The Entity-Relationship Model Chapter 2 What are the steps in designing a database ? Why is the ER model used to create an initial design?
The Entity-Relationship Model
The Entity-Relationship Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Text-Book Chapters (7 and 8) Entity-Relationship Model
1 Lecture 3: The relational model E.F. Codd.
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.) –What are the entities.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Modeling Your Data Chapter 2. Overview of Database Design Conceptual design: –What are the entities and relationships in the enterprise? – What information.
The Entity- Relationship Model CS 186 Fall 2002: Lecture 2 R &G - Chapter 2 A relationship, I think, is like a shark, you know? It has to constantly move.
The Entity-Relationship (ER) Model CS541 Computer Science Department Rutgers University.
1 Data Modeling Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
ER continued, and ER to Relational Mappings R&G Chapters 2, 3 Lecture 22.
1 The Entity-Relationship Model Chapter 2. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas.
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
Data Modeling Using the Entity-Relationship Model
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design : (ER Model is used at this stage.)  What are the entities.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
Entities and Attributes
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Chapter 2.  Conceptual design: (ER Model is used at this stage.) ◦ What are the entities and relationships in the enterprise? ◦ What information about.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
CMPT 258 Database Systems The Entity-Relationship Model Part II (Chapter 2)
ICS 321 Spring 2011 High Level Database Models Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 2/7/20111Lipyeow.
Christoph F. Eick: Designing E/R Diagrams 1 The Entity-Relationship Model Chapter 3+4.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Initial Design of Entity Types for the COMPANY Database Schema Based on the requirements, we can identify four initial entity types in the COMPANY database:
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
Chapter 3 Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
09/03/2009Lipyeow Lim -- University of Hawaii at Manoa 1 ICS 321 Fall 2009 Introduction to Database Design Asst. Prof. Lipyeow Lim Information & Computer.
1 Conceptual Design using the Entity- Relationship Model.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
The Entity-Relationship (ER) Model. Overview of db design Requirement analysis – Data to be stored – Applications to be built – Operations (most frequent)
CSC 411/511: DBMS Design 1 1 Dr. Nan WangCSC411_L2_ER Model 1 The Entity-Relationship Model (Chapter 2)
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Enhanced Entity-Relationship and UML Modeling. 2.
ENTITY- RELATIONSHIP MODELLING 1 All rights reserved by
Topic 3: ER – Entity Relationship Model (ERM) 6/12/
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
A short review on entity- relationship modelling.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
COP Introduction to Database Structures
Lecture 5 Supplement – ER Model & Mapping to Relational Model
MODELS OF DATABASE AND DATABASE DESIGN
The Entity-Relationship Model
Instructor: Elke Rundensteiner
DATABASE MANAGEMENT SYSTEMS
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship Model
The Entity-Relationship (ER) Model
Presentation transcript:

Lecture 2: Entity/Relationship modelling Dr. Peter Chen http://bit.csc.lsu.edu/~chen/ www.cl.cam.ac.uk/Teaching/current/Databases/

Database design lifecycle Requirements analysis User needs; what must database do? Conceptual design High-level description; often using E/R model Logical design Translate E/R model into (typically) relational schema Schema refinement Check schema for redundancies and anomalies Physical design/tuning Consider typical workloads, and further optimise Today

Today’s lecture E/R modelling Extended E/R modelling Entities Attributes Relationships Constraints on relationships Extended E/R modelling Object ideas

Conceptual Design What are the entities and relationships in the enterprise? What information about these entities and relationships should we store in the database? What are the integrity constraints (business rules) that hold? We can represent this information pictorially in E/R diagrams (and then map these to a relational schema later).

E/R basics An entity is a real-world object that is distinguishable from other objects Each entity has attributes (with domains) A particular entity will have a value for each of its attributes An entity type defines a set of entities that have the same attributes An entity set is the collection of all entities of a particular entity type (at a particular point in time)

Entities and attributes Entity types are drawn as rectangles, e.g. Attributes are drawn as ovals, and attached to the entity sets with lines, e.g. Employees NI dob Name Employees

Key attributes A key attribute of an entity type is an attribute whose values are distinct for each entity Sometimes several attributes (a composite attribute) together form a key NB: Such a composite should be minimal We underline key attributes NI dob Name Employees

Relationships A relationship type among two or more entity types defines a set of associations between entities from those types Mathematically, relationship type R R  E1    En. The set of instances of the relationship type is called the relationship set

Relationships in E/R Relationship types are represented by diamonds They connect the participating entity types with straight lines, e.g. DID budget dname Departments NI dob Name Employees Works_in

Relationship set diagrams Sometimes its useful to represent the relationship set diagrammatically r1 d1 e1 r2 d2 e2 e3 r3 d3 e4 d4 r4 e5 d5 … … …

Relationship attributes Relationships can also have attributes NB: A relationship must be uniquely determined by the entities, without reference to the relationship attributes Works_in NI dob Name Employees DID budget dname Departments since

N-ary relationships Although relatively rare, we can have n-ary relationships, e.g. Works_in2 NI dob Name Employees DID budget dname Department since Locations address capacity

Recursive relationships Each entity type in a relationship plays a particular role, which is associated with a role name (this is usually suppressed) An recursive relationship is when an entity type plays more than one role in the relationship type In this case the role name is required

Recursive relationships in E/R e.g. Employees Reports-to NI name dob subordinate supervisor

Constraints on relationship types For example: An employee can work in many departments; a department can have many employees In contrast, each department has at most one manager Thus we need to be able to specify the number of relationship instances that an entity can participate in. For binary relationships the possible ratios are: 1:1, 1:N, N:1, M:N

Cardinality ratios 1:1 1:N M:N

Cardinality ratios in E/R M M:N 1 N N:1 1 1 1:1 Note: Sometimes this is written using different arrowheads

Participation constraints Every department must have a manager This is an example of a participation constraint The participation of an entity set, E, in a relationship set R is said to be total if every entity in E participates in at least one relationship in R. (If not its participation is said to be partial)

Participation in E/R diagrams Total participation is displayed as a bold line between the entity type and the relationship NB. Sometimes this is written as a double line DID budget dname Department NI dob Name Employees since N 1 Manages

Weak entity types An entity type may not have sufficient attributes to form a primary key Such an entity type is called a weak entity type A weak entity can only be identified uniquely by considering the primary key of another (owner) entity

Weak entity types cont. Thus the owner and weak entity types must participate in a 1:N relationship Weak entity set must have total participation in this identifying relationship set. Employees NI Name Policy Dependents Cost pName age 1 N

Extended E/R modelling What we’ve seen so far is “classic” E/R Over the years a number of features have been added to the model and the modelling process These features include: Sub- and super-classes Specialisation Generalisation Categories Higher/Lower-level entity sets Attribute inheritance Aggregation

ISA hierarchies We can devise hierarchies for our entity types If we declare A ISA B, every A entity is considered to be a B entity Employees ISA Temp_Emp Contract_Emp hours rate cid NI Name dob

Attribute inheritance As we’d expect, attributes of superclasses are inherited by the subclasses. Thus: Temp_Emp also has attributes NI, Name and dob In fact, subclasses inherit relationships too

Aggregation Suppose we have an entity set of Projects and that each project is sponsored by one or more departments; thus Sponsors Departments Projects PID start budget since DID dname N M

Aggregation cont. Suppose that employees are assigned to monitor a sponsorship Monitors should be a relationship between Employees and the Sponsors relationship Aggregation allows us to indicate that a relationship set participates in another relationship set Use dashed box

Aggregation cont. Employees N M NI name Monitors until since start dname PID budget DID budget N Sponsors M Projects Departments

A Data Model from the European Bioinformatics Institute (EBI) See http://intact.sourceforge.net/uml/intactCore.gif

Summary You should now understand: Database design lifecycle Entities and attributes Relationships Cardinality ratios Participation constraints Weak entity types ISA hierarchies & aggregation Next lecture: The relational model