The Entity-Relationship Model

Slides:



Advertisements
Similar presentations
Database Systems: Design, Implementation, and Management Tenth Edition
Advertisements

Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Entity Relationship (ER) Modeling
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
Chapter 4 Notes. Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
Entity-Relationship Model. The process of designing a database begins with: –an analysis of what information the database must hold, and –the relationships.
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
System Concepts and Architecture Rose-Hulman Institute of Technology Curt Clifton.
Entity-Relationship Model
Chapter 4 Entity Relationship (E-R) Modeling
2 1 Chapter 2 Data Model Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Entities and Attributes
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
2 1 Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Ninth Edition
Chapter 5 Entity Relationship (ER) Modelling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
CSET 3300 Databases & ER Data Models. Databases A database is a collection of data (information). A DataBase Management System (DBMS) is a software system.
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Rob and Coronel Adapted for INFS-3200.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Databases : Entity-Relationship Model 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey D. Ullman.
Chapter Two ( Data Model) Objectives Introduction to Data Models What are the Data Models Why they are important Learn how to design a DBMS.
1 Chapter 2 Data Model Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Entity-Relationship Model
Databases 1 Fifth lecture. Entity-Relationship Model Diagrams Class hierarchies Weak entity sets From E/R diagrams to Relations 2.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Entity-Relationship Model E/R Diagrams Converting E/R Diagrams to Relations.
2 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Data Models Why data models are important About the basic data-modeling.
Data Models. 2 The Importance of Data Models Data models –Relatively simple representations, usually graphical, of complex real-world data structures.
Database Design and Programming Jan Baumbach Adopted from previous slides of Peter Schneider-Kamp.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture.
Entity Relationship (E-R) Model
Data Modeling Using the Entity- Relationship (ER) Model
CS422 Principles of Database Systems Entity-Relationship Model
COP Introduction to Database Structures
Comp 1100 Entity-Relationship (ER) Model
Database Systems: Design, Implementation, and Management Tenth Edition
Session 2 Welcome: To the fourth learning sequence
Database Development Lifecycle
Data Modeling Using the Entity- Relationship (ER) Model
Entity-Relationship Model
TMC2034 Database Concept and Design
Business System Development
Entity-Relationship Diagrams
COP4710 Database Systems E-R Model.
Entity-Relationship Model
CS311 Database Management system
Outline of the ER Model By S.Saha
Constraints in Entity-Relationship Models
CPSC-310 Database Systems
Database Management system
Instructor: Zhe He Department of Computer Science
The Entity-Relationship Model
CPSC-310 Database Systems
Chapter 4 Entity Relationship (ER) Modeling
Entity-Relation Modeling
Review of Week 1 Database DBMS File systems vs. database systems
ITEC 3220A Using and Designing Database Systems
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 4 Entity Relationship (ER) Modeling
Guide to Modeling Keys to E-R diagrams.
CS4433 Database Systems E-R Model.
Guide to Modeling Keys to E-R diagrams.
Entity Relationship (ER) Modeling
Chapter 3: Multivalued Dependencies
Presentation transcript:

The Entity-Relationship Model

Basic Database Terminology Data model : describes high-level conceptual structuring of data Example: Data is set of student records, each with ID, name, address, and courses Example: Data is a graph where nodes represent proteins and edges represent chemical bonds between proteins Schema describes how data is to be structured and stored in a database Defined during creation of the database Schemas rarely change Data is actual “instance” of database Updated continuously Changes rapidly

The Importance of Data Models Relatively simple representation, usually graphical, of complex real-world data structures Communications tool to facilitate interaction among the designer, the applications programmer, and the end user Good database design uses an appropriate data model as its foundation CC414- Dr. Amani Saad - Database Systems: Design, Implementation, & Management, Rob & Coronel

Importance of Data Modeling End-users have different views and needs for data Data model organizes data for various users CC414- Dr. Amani Saad - Database Systems: Design, Implementation, & Management, Rob & Coronel

Why Learn About Database Modeling? The way in which data is stored is very important for subsequent access and manipulation by SQL. Properties of a good data model: It is easy to write correct and easy to understand queries. Minor changes in the problem domain do not change the schema. Major changes in the problem domain can be handled without too much difficulty. Can support efficient database access.

The Evolution of Data Models Hierarchical Network Relational Object oriented Object Relational CC414- Dr. Amani Saad - Database Systems: Design, Implementation, & Management, Rob & Coronel

Business Rules (enforce Constraints) Brief, precise, and unambiguous description of a policy, procedure, or principle within a specific organization’s environment Apply to any organization that stores and uses data to generate information Description of operations that help to create and enforce actions within that organization’s environment CC414- Dr. Amani Saad - Database Systems: Design, Implementation, & Management, Rob & Coronel

Business Rules Must be rendered in writing Must be kept up to date Sometimes are external to the organization Must be easy to understand and widely disseminated Describe characteristics of the data as viewed by the company CC414- Dr. Amani Saad - Database Systems: Design, Implementation, & Management, Rob & Coronel

Sources of Business Rules Company managers Policy makers Department managers Written documentation Procedures Standards Operations manuals Direct interviews with end users CC414- Dr. Amani Saad - Database Systems: Design, Implementation, & Management, Rob & Coronel

Importance of Business Rules Promote creation of an accurate data model Standardize company’s view of data Constitute a communications tool between users and designers Allow designer to understand the nature, role, and scope of data Allow designer to understand business processes Allow designer to develop appropriate relationship participation rules and constraints CC414- Dr. Amani Saad - Database Systems: Design, Implementation, & Management, Rob & Coronel

Purpose of E/R Model The E/R model allows us to sketch the design of a database informally. Represent different types of data and how they relate to each other Designs are pictures called entity-relationship diagrams. Fairly mechanical ways to convert E/R diagrams to real implementations like relational databases exist.

Entity Sets Entity = “thing” or object. Entity set = collection of similar entities. Similar to a class in object-oriented languages. Attribute = property of an entity set. Generally, all entities in a set have the same properties. Attributes are simple values, e.g. integers or character strings.

Attributes Database Systems, 8th Edition

Attributes (continued) Characteristics of entities Required attribute: must have a value Optional attribute: may be left empty Domain: set of possible values for an attribute Attributes may share a domain Database Systems, 8th Edition

Attributes (continued) Composite attribute can be subdivided Simple attribute cannot be subdivided Single-value attribute can have only a single value Multivalued attributes can have many values Database Systems, 8th Edition

Attributes (continued) M:N relationships and multivalued attributes should not be implemented Create several new attributes for each of the original multivalued attributes components Create new entity composed of original multivalued attributes components Derived attribute: value may be calculated from other attributes Need not be physically stored within database Database Systems, 8th Edition

E/R Diagrams In an entity-relationship diagram, each entity set is represented by a rectangle. Each attribute of an entity set is represented by an oval, with a line to the rectangle representing its entity set.

Example drinks name manf Entity set drinks has two attributes, name and manf (manufacturer). Each drink entity has values for these two attributes, e.g. (coke, Anheuser-Busch)

Relationships A relationship connects two or more entity sets. It is represented by a diamond, with lines to each of the entity sets involved.

Example Note: license = drink, full, none cafes name license addr drinks manf name Sells cafes sell some drinks. Frequents Drinkers frequent some cafes. Likes Drinkers like some drinks. Drinkers addr name

Relationship Set The current “value” of an entity set is the set of entities that belong to it. Example: the set of all cafes in our database. The “value” of a relationship is a set of lists of currently related entities, one from each of the related entity sets.

Example A relationship R between entity sets E and F relates some entities in E to some entities in F. R is a set of pairs of tuples (e, f ) where e is in E and f is in F. For the relationship Sells, we might have a relationship set like: cafe drink Joe’s cafe coke Joe’s cafe pepsi Sue’s cafe coke Sue’s cafe apple juice Sue’s cafe coke Lite

Multiway Relationships Sometimes, we need a relationship that connects more than two entity sets. Suppose that drinkers will only drink certain drinks at certain cafes. Our three binary relationships Likes, Sells, and Frequents do not allow us to make this distinction. But a 3-way relationship would.

Example name addr name manf cafes drinks license Preferences Drinkers

A Typical Relationship Set cafe Drinker drink Joe’s cafe Ann pepsi Sue’s cafe Ann coke Sue’s cafe Ann apple juice Joe’s cafe Bob coke Joe’s cafe Bob pepsi Joe’s cafe Cal pepsi Sue’s cafe Cal coke Lite

Many-Many Relationships Think of a relationship between two entity sets, such as Sells between cafes and drinks. In a many-many relationship, an entity of either set can be connected to many entities of the other set. E.g., a cafe sells many drinks; a drink is sold by many cafes.

Many-One Relationships Some binary relationships are many -one from one entity set to another. Each entity of the first set is connected to at most one entity of the second set. But an entity of the second set can be connected to zero, one, or many entities of the first set.

Example Favorite, from Drinkers to drinks is many-one. A drinker has at most one favorite drink. But a drink can be the favorite of any number of drinkers, including zero.

One-One Relationships In a one-one relationship, each entity of either entity set is related to at most one entity of the other set. Example: Relationship Best-seller between entity sets Manfs (manufacturer) and drinks. A drink cannot be made by more than one manufacturer, and no manufacturer can have more than one best-seller (assume no ties).

Representing “Multiplicity” Show a many-one relationship by an arrow entering the “one” side. Show a one-one relationship by arrows entering both entity sets. In some situations, we can also assert “exactly one,” i.e., each entity of one set must be related to exactly one entity of the other set. To do so, we use a rounded arrow.

Example Likes Drinkers drinks Favorite

Example Consider Best-seller between Manfs and drinks. Some drinks are not the best-seller of any manufacturer, so a rounded arrow to Manfs would be inappropriate. But a manufacturer has to have a best-seller (we assume they are drink manufacturers). Best- seller Manfs drinks

Attributes on Relationships Sometimes it is useful to attach an attribute to a relationship. Think of this attribute as a property of tuples in the relationship set. Sells cafes drinks price Price is a function of both the cafe and the drink, not of one alone.

Relationships Can the same entity set appear more than once in the same relationship? Prerequisite relationship between two Courses Which course is the pre-requisite?

Roles Label the edges between the relationship and the entity set with names called roles.

Example Relationship Set Husband Wife Bob Ann Joe Sue … … Drinkers … … Drinkers Married husband wife

Example Relationship Set buddy1 buddy2 Bob Ann Joe Sue Ann Bob Joe Moe … … buddies 1 2 Drinkers

Parallel Relationships Can there be more than one relationship between the same pair of entities? TA and Take relationship between Students and Classes

Subclasses Subclass = special case = fewer entities = more properties. Example: Juices are a kind of drink. Not every drink is a juice, but some are. Let us suppose that in addition to all the properties (attributes and relationships) of drinks, juices also have the attribute fruit.

Subclasses in E/R Diagrams Assume subclasses form a tree. i.e., no multiple inheritance. Isa triangles indicate the subclass relationship. Point to the superclass.

Example drinks name manf isa Juices fruit