Download presentation
Presentation is loading. Please wait.
1
--The Entity Relationship Model(1)--1 The Entity Relationship Model
2
--The Entity Relationship Model(1)--2 Outline ER model Overview Entity types Attributes, keys Relationship types Weak entity types uses Integration DEFinition for Information Modeling (IDEF1X) notation in Erwin EER model Subclasses Specialization/Generalization Schema Design Single DB View integration in IS
3
--The Entity Relationship Model(1)--3 Data Modelling Process Mini-world requirements collection and analysis conceptual design physical design database requirements conceptual schema logical schema internal schema data model mapping DBMS- specific DBMS- independent
4
--The Entity Relationship Model(1)--4 Entity-Relationship Model This model is used in conceptual design. Popular in CASE tools, e.g., SSADM, DataArchitect A database can be modelled as a collection of entity types, and relationships among entity types. Result is an ER Schema or an ER Diagram.
5
--The Entity Relationship Model(1)--5 MiniWorld Definition: A miniworld is a part of the real world that we are interested in modelling.
6
--The Entity Relationship Model(1)--6 Entity Definition: An entity is an object that exists and is distinguishable from other objects. Object, exists, distinguishable DVD store mini-world example Physically exist The CUSTOMER Jane Doe. The Xtra-vision STORE. The EMPLOYEE Juan Gonzales.
7
--The Entity Relationship Model(1)--7 Entity, cont. Abstract or organisational entities that do not exist physically The Introduction to Databases COURSE. The SCHOOL of Computing. Events The TUTORIAL on Friday, October 31, 2007. The EXAMINATION on Tuesday December 15, 2007.
8
--The Entity Relationship Model(1)--8 Attribute Definition: An attribute is a property of an entity. Feature example: CUSTOMER Name Date of Birth (DOB) example: DVD Copy number Title CUSTOMER entity examples Name=Jane, DOB=1/1/70 Name=Joe, DOB=5/6/75
9
9 Entity Type Definition: An entity set is a set of entities of the same type. Definition: An entity type is a description of the attributes that a set of entities has in common. Entity set: a set of actual entities Entity type: the ideal description of a kind of entity Example: A CUSTOMER entity type. A CUSTOMER has a name and a date of birth (DOB). Name=Joe, DOB=5/6/75 Name=Julius, DOB=9/7/55 Name=Jane, DOB=1/1/70 CUSTOMER entities CUSTOMER entity sets Name=Fred, DOB=8/2/64
10
10 Entity Type, cont. Focus on attributes of an ideal entity An entity has a value for every attribute of the entity type Use a null value to represent the following. An unknown attribute value A Customer’s Address is unknown. An inapplicable attribute value A Customer’s Phone number is inapplicable if that person does not own a phone. Name=Jane, DOB=@ CUSTOMER entities unknown date of birth Name=Fred, DOB=8/2/64
11
11 Distinguishing Entities How can entities be distinguished from each other? Assumption: Each entity will have a unique combination of attribute values. Example, assume the Customer entity type has Name and DOB attributes. There may be several Customers with a Name of ‘Joe’. Also, there may be several Customers with a DOB of 5/6/75. But there can be at most one Customer with the Name ‘Joe’ and a DOB of 5/6/75. Is there a smaller such set of attributes? Name=Joe, DOB=10/7/49 CUSTOMER entities Name=Fred, DOB=5/6/75 Name=Joe, DOB=5/6/75
12
--The Entity Relationship Model(1)--12 Keys Definition: A super key of an entity type is a set of one or more attributes whose values uniquely determine each entity. Assume each Customer has a unique ID. The following are super keys. {Name, DOB, ID}, {Name, ID}, {Name, DOB}, {DOB, ID}, {ID} Definition: A candidate key is a minimal super key. {Name, DOB} is a candidate key of Customer. {ID} is a candidate key of Customer. Definition: Generally, there are may be several candidate keys. One of the keys is selected to be the primary key. {ID} is the primary key of Customer.
13
--The Entity Relationship Model(1)--13 ER Diagram - Diamond Notation An entity type is represented with a labelled rectangle. An attribute is represented with a labelled oval, connected to an entity type with a line. Customer Name DOB
14
--The Entity Relationship Model(1)--14 Attributes - Diamond Notation Single valued versus multi-valued E.g., multiple telephone extensions Simple attributes versus structured attributes E.g., an address is composed of a number, a street, a city and a state CustomerExtension Address Street City State Customer
15
--The Entity Relationship Model(1)--15 Attributes, cont. Stored versus derived E.g., an age can be derived from a stored birthdate Additional constraints - not represented in a diagram Null versus non-null Domain constrained E.g., a student number must be exactly 9 decimal digits Customer DOB Age
16
--The Entity Relationship Model(1)--16 Keys in ER Diagrams An attribute that is part of the (primary) key is underlined. E.g., ID uniquely identifies customers Assume no two customers with the same name live at the same address. Customer Name Address ID Customer Name Address ID
17
--The Entity Relationship Model(1)--17 Relationship Definition: A relationship is an object that associates entities. Joe Jenkins Jane Doe Finding Nemo copy 1 Babe copy 3 Customer entities DVD entities relationship objects
18
18 Relationship sets Definition: A relationship set is a specific set of associated objects between entities of the same entity types. {(e 1, e 2,..., e n ) | e 1 E 1 e 2 E 2 .... e n E n } where the relationship is (e 1, e 2,..., e n ). Example is the set {(Joe Jenkins, Eraserhead copy 1), (Joe Jenkins, Babe copy 3)} Joe Jenkins Jane Doe Eraserhead copy 1 Babe copy 3 Customer entities Video Tape entities
19
--The Entity Relationship Model(1)--19 Relationship types Definition: A relationship type describes a relationship set. A relationship type is an ideal form (Plato), a kind, a type. Example: The Rents relationship type relates the entity type Customer with the entity type DVD, capturing which customers currently rent DVDs.
20
20 Relationship Types - Diamond Notation A relationship type is represented with a labelled diamond, and has lines to each of the entity types it relates. The relationship type could have attributes. A relationship type does not have key attribute(s) – the key comes from entity types that it relates. Customer Rents DVD Name Customer ID Return Date Location Address
21
21 DVD Store Database Example A DVD is an entity type with attributes DVD Number, Film ID (the key attributes), and Status A Customer is an entity type with attributes Customer ID (the key), Name, Address Rents is a relationship type with attributes Return Date, Amount Paid CustomerRentsDVD
22
22 Example, cont. The entity-relationship diagram for the above example is: Name Customer Rents DVD Name Address Customer ID Return Date Amount PaidStatus DVD Number Film ID Customer Rents Entity TypeAttributeRelationship Type Where:
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.