ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 1

Similar documents
Introductory SQL SQL Joins: Viewing Relationships Pg 1

ER Modeling Data Modeling and the Entity-Relationship (ER) Diagram Pg 1

Advanced SQL GROUP BY Clause and Aggregate Functions Pg 1

Chapter 4. In this chapter, you will learn:

Common Data Model Patterns Ray Lockwood 1 Points: Certain patterns recur in data models. We should recognize and name these patterns.

Referential Integrity and Other Table Constraints Ray Lockwood

Entity-Relationship Model &

Surrogate Keys Ray Lockwood

More on the Chen Notation

course 3 Levels of Database Design CSCI 403 Database Management Mines Courses ERD Attributes Entities title 9/26/2018

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

Unified Modeling Language (UML)

Major components of ER diagram Practices

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

Relational Model (cont d) & Entity Relational Model. Lecture 2

Entity-Relationship Models

A l Ain University Of Science and Technology

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

MIS2502: Data Analytics Relational Data Modeling - 1. JaeHwuen Jung

Chapter 17. Methodology Logical Database Design for the Relational Model

A l Ain University Of Science and Technology

Non-overlappingoverlapping. Final outcome of the worked example On pages R&C pages R&C page 157 Fig 3.52

ER to Relational Mapping

Database Design and Administration for OnBase WorkView Solutions. Mike Martel Senior Project Manager

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

ER Model. Objectives (2/2) Electricite Du Laos (EDL) Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Agenda: Understanding Relationship Types Degree and Cardinality with Examples

DATABASE SYSTEMS. Chapter 5 Entity Relationship (ER) Modelling DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT

Data Analysis 1. Chapter 2.1 V3.1. Napier University Dr Gordon Russell

In This Lecture. The Relational Model. The Relational Model. Relational Data Structure. Unnamed and named tuples. New thing:scheme (and attributes)

Assorted Topics Stored Procedures and Triggers Pg 1

Entity Relationship Modelling

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

Relational Database Components

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Represent entities and relations with diagrams

SUMMER EXAMINATIONS 2013

Related download: Instructor Manual for Modern Database Management 12th Edition by Hoffer Venkataraman Topi (Case studies included)

Requirement Analysis & Conceptual Database Design

Database Management System 6 ER Modeling...

How to translate ER Model to Relational Model

Database Management Systems LECTURE NOTES 2

David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation

Database Management Systems

Handout 2. A very brief intro to relational databases (with more coming later). Conceptual Data Modeling Entity-Relationship Diagrams.

Lecture 3. Wednesday, September 3, 2014

Objectives Definition iti of terms List five properties of relations State two properties of candidate keys Define first, second, and third normal for

Data, Databases, and DBMSs

The Entity-Relationship Model (ER Model) - Part 2

3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key

ER DIAGRAM ER) diagram, a graphical representation of entities and their relationships to each other, typically used in computing in regard to the

A hypothetical M:M student schedule example

Entity-Relationship Model. From Chapter 5, Kroenke book

LECTURE 3: ENTITY-RELATIONSHIP MODELING

DATABASE DEVELOPMENT (H4)

Intro to DB CHAPTER 6

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

Chapter 4 Entity Relationship Modeling In this chapter, you will learn:

IS 263 Database Concepts

4. Entity Relationship Model

CSE 530A. ER Model to Relational Schema. Washington University Fall 2013

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

Fundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.

Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005.

Chapter 6: Entity-Relationship Model

CSE 880:Database Systems. ER Model and Relation Schemas

Database Systems. Overview - important points. Lecture 5. Some introductory information ERD diagrams Normalization Other stuff 08/03/2015

Full file at

Chapter 7: Entity-Relationship Model

CS 405G: Introduction to Database Systems

L12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

LAB 3 Notes. Codd proposed the relational model in 70 Main advantage of Relational Model : Simple representation (relationstables(row,

CMP-3440 Database Systems

Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

In mathematical terms, the relation itself can be expressed simply in terms of the attributes it contains:

Relational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Attributes. Entity-Relationship Model (ERM) IV. Entity Relationship Modeling. Entities and Attributes: Chen and Crow s Foot

Entity-Relationship Model

CS425 Midterm Exam Summer C 2012

Step 2: Map ER Model to Tables

2004 John Mylopoulos. The Entity-Relationship Model John Mylopoulos. The Entity-Relationship Model John Mylopoulos

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

ER modeling. Lecture 4

CSCC43H: Introduction to Databases

CSIT5300: Advanced Database Systems

Logical Database Design. ICT285 Databases: Topic 06

The entity is an object of interest to the end user. entity correspond to the table not to a row- in the relational environment.

Chapter 7: Entity-Relationship Model

The Entity Relationship Model

Chapter 1 SQL and Data

ENTITY-RELATIONSHIP MODEL

Chapter 7: Entity-Relationship Model

COMP 430 Intro. to Database Systems

Lecture 10 - Chapter 7 Entity Relationship Model

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

How to get online with us (New Instructions dated February 2015) We had to change providers for the Ventrilo program. What this means for those who

Transcription:

ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 1 ER Diagram ID-Dependent and Weak Entities Ray Lockwood Points: An ID-dependent entity is an entity whose identifier (key) includes the identifier of another entity. A weak entity is one whose existence depends on the presence of another entity. A strong entity is an entity that isn't weak. All ID-dependent entities are weak, but not all weak entities are ID-dependent. Terminology We might be blending our terminology a little here. These are terms that apply to the ER Model, to the Relational Model, and to the Database view of things: ER Model Relational Model Database Entity Relation Table Attribute Attribute Column Instance Tuple Row Identifier Key Key Relationships In the ER Diagram and the Relational Model Relationships in an ER diagram aren't implemented by foreign keys. They're made by drawing lines from one entity to another. Part of the transformation from an ER diagram to a database is adding foreign key columns to tables to implement the relationships. Another Look At Some Old Tables Here's our and tables: People mix up their terminology all the time. The ER Diagram is at a higher level of abstraction than the Relational Database. We don t have to worry about the mechanics of foreign keys when working with an ER Diagram. Num LastName FirstName DeptNum 014 Smith Bob 100 086 Jones Bill 200 127 Doe John 100 192 Doe Jane 300 Num LastName FirstName Relationship 014 Smith Susan Wife 014 Smith Billy Son 014 Smith John Son 192 Doe Jane Wife 192 Doe Mary Daughter 428 Smith Betty Wife No primary key yet

ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 2 Here s the ER Diagram in different styles: Identifying relationship 1 Participation constraint M This one is old fashioned. 1 0..M This is a little better. Participation constraint (same as 1..1) Participation constraint Identifying relationship (Solid line) (Rounded corners) This is how modern data modeling tools draw an ER diagram. Notice all the double lines in the original style diagram: The double outline in the relationship diamond indicates an identifying relationship. That means the key of contains the key of as one of its components. The double line leading from the diamond to is called a constraint and indicates a mandatory in the relationship. Every row must be associated with an row. The double outline on the entity means that is a weak entity. A row of can't exist on its own without a corresponding instance. We ll examine these concepts below. Let s Make a Primary Key in the Table Remember we said that we hadn t gotten around to giving the table a primary key? We'll do that now by adding a FamMbrId attribute: Composite Key ( multiple attributes) New attribute added to make the key unique. Num FamMbrId LastName FirstName Relationship 014 01 Smith Susan Wife 014 02 Smith Billy Son 014 03 Smith John Son 192 01 Doe Jane Wife 192 02 Doe Mary Daughter 428 01 Smith Betty Wife FamMbrId is a sequential number that starts over for each Num. The key of is a Composite Key because it's composed of multiple attributes.

ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 3 Composite Key The attributes Num+FamMbrId combine to form the primary key of. A key made up of more than a single attribute is called a composite key. Cardinality Refresher Maximum Cardinality Notice the maximum cardinalities in the ER Diagram. One row can be connected to many rows, but a row can be connected to only one row. This is called a one-to-many relationship. There are three types of maximum cardinality ratios: One-to-one (1:1) One-to-Many (1:M) Many-to-Many (M:M) Maximum cardinality tells us how many rows can participate in a relationship. Minimum Cardinality Now look at the minimum cardinalities. An row is required to have at least zero s. This is called an optional constraint and is indicated by either: The zero in the 0..M near the entity in the old style. The near the entity in the crow s foot style. Notice that in the other direction, there is no choice in cardinality. Minimum cardinality for a row is the same as the maximum cardinality: one. This is shown by: The one (without a zero) near the entity in the old style. The near the entity in the crow s foot style. When the minimum cardinality is greater than zero, it s called a mandatory constraint. Minimum Cardinality tells us at least how many rows must participate in a relationship. The full minimum cardinality specification is Optional-to-, or O-M. Optional and Participation What makes the relationship of to mandatory? It s the company s rule that to be called a family member, a person must be in the family of an employee. A key can be composed of any number of attributes. A Composite Key has more than one attribute. A little review. Maximum cardinality is the most important characteristic of a relationship. Maximum cardinality tells how many rows can potentially be associated with another row. Minimum cardinality tells at least how many rows must be associated with another row. An can optionally have a. A must belong to an. means (in this case) that a child row must have a parent. Frequently, minimum determined by business rules.

ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 4 There are other such obvious rules: For example, we can t have a room without having a building in which the room is located. However, we could have a building that hasn t been divided into rooms. Room-to-Building is therefore an Optional-to- relationship. ID-Dependent Entities Look at the two tables again: Num LastName FirstName DeptNum 014 Smith Bob 100 086 Jones Bill 200 127 Doe John 100 192 Doe Jane 300 Part of the key of is also the key of. Num FamMbrId LastName FirstName Relationship 014 01 Smith Susan Wife 014 02 Smith Billy Son 014 03 Smith John Son 192 01 Doe Jane Wife 192 02 Doe Mary Daughter 428 01 Smith Betty Wife The primary key in the table is the composite of Num+ FamMbrId. There is something critically important about this key: The key of contains an attribute that is the key of another entity. The Num attribute, which is part of the key of, is the key of. We have a special name for this. is what we call an ID-Dependent entity. It s impossible for a row to exist without a corresponding row. The definition of an ID-dependent entity is an entity whose identifier (key) contains the key of another entity. The Num attribute is a key of the entity, and is used as the foreign key in the table. Merely having a foreign key is not significant; it s the fact that this attribute is part of the key of that makes this entity ID- Dependent. is ID-Dependent on. Part of the key of is the whole key of. An ID-Dependent entity is one whose key contains the key of another entity. An ID-Dependent row cannot exist without its parent row in the other table.

ER Modeling ER Diagram ID-Dependent and Weak Entities Pg 5 Weak Entities & Strong Entities If we were to delete an row that had rows attached, what would happen to those rows? The Num in their primary key would no longer be valid. They are no longer family members of an employee, and they should be deleted from the database, too. A rule to enforce this is called a referential integrity constraint. A Weak Entity is an entity whose existence depends on the existence of another entity. All ID-dependent entities are weak, but not all weak entities are ID-dependent. A Strong Entity is any entity that isn't weak. A strong entity s existence doesn't depend on the existence of some other entity. Weak Entities Are Not Necessarily ID-Dependent All ID-dependent entities are weak, but not all weak entities are ID-dependent. An example of a weak entity that isn t ID-dependent is the relationship of an Automobile to its Model number. The model is the automobile s design. We can say this car is a Buick Skylark but we can t say this car is not any model, it s just a car. There can t be an automobile without a design, so the Automobile entity is weak to the Model entity. Referential integrity rules that make sure there are no orphan rows. Possible 1. Automatically delete children. 2. Prevent deleting parents with children. Weak entities cannot exist without the existence of another entity. All ID-dependent entities are weak, but not all weak entities are ID-dependent. But an automobile s identifier is its serial number which isn't related to the model number. So the relationship between Automobile and Model is not ID-dependent, although Automobile is still a weak entity and can't exist without the Model. A Relationship Does Not Make an Entity Weak All weak entities have a mandatory relationship, but not all entities with a mandatory relationship are weak. For example, the University requires all students to have an advisor, so the relationship of Student to Advisor is mandatory. We can t have a student without an advisor. But this is the result of a business rule. The existence of a student doesn t depend on the existence of an advisor. If an advisor left the university, the students he advised would still exist. This means that Student is a strong entity even though it participates in a mandatory relationship. means that the minimum cardinality is greater than zero. does not make an entity weak.