Download presentation
Presentation is loading. Please wait.
Published byAugustine Boone Modified over 9 years ago
1
Things are bad. Children no longer obey their parents and everyone is writing a book. -- Marcus Tillius Cicero
2
Entity Relationship Diagram What Is It? A graphical diagram representing the data relationships in a problem area Often referred to as E/RD
3
Entity Relation Diagram StudentClass Enrolls in S_No S_Name C_No C_Name Entities Relationship Attribute Key
4
IDEF1X Diagram This is an entity This is a relation, in this case, a 1:m An associative entity
5
Entity-Relationship Diagram Consists of Entities Relationships Keys Attributes Is not necessarily Normalized
6
Entity Any distinguishable person, place, thing, event, or concept about which information is kept. An Entity has attributes of interest that you want to store. Entity Instance – A single occurrence of an entity.
7
Naming Entities Be careful naming entities, consider: To a dog breeder Collie may be an entity To a veterinarian Large Dog may be an entity To a pet shop Dog may be an entity To a rental firm Pet may be an entity The trick is to know whether you have found an entity or an instance
8
Entity Instance Instance means a single member of an entity; a member of the set. It might eventually be defined as a row in a table. In relational set theory, it would be called a tuple.
9
Associative Entity An Associative or Intersection Entity is a juncture between two entities They are generally created as the result of a many to many relationship
10
Entities Entities are represented as boxes Square cornered boxes represent independent entities Rounded cornered boxes represent dependent entities More on this later
11
Example of Entities Student Student Number Student Name Street Address City State Zip Code Phone Number Birth Date Entity Title Entity Box Primary Key Attributes
12
Relationship A connection between two entities
13
Relationships Relationships are represented as lines They are two sided, theyconnect two entities They have names The connection between entities and relationships can be stated as sentences, which are the business rule One Instructor Teaches Many Classes
14
Types of Relationships Identifying Relationships Non-Identifying Relationships Recursive Relationships
15
Identifying Relationship It is necessary to know the parent to uniquely identify the child The Child will be an associative entity
16
Non-identifying Relationship It is not needed to know the Parent to uniquely define the child The Child will not be an associative entity (at least in this relationship)
17
Recursive Relationship A relation points an entity back to itself The key of the parent becomes an attribute of the child A recursive relationship is non- identifying
18
More about Entities Entities can exist in two forms Independent Entity Either Entity can exist without a relationship to the other Dependent Entity A Dependent Entity must be tied to one or more Independent Entities
19
More About Relationships Relationships can be: Identifying Relationships Ties an Independent Entity and a Dependent Entity together Non-Identifying Relationships Ties two (or more) Independent Entities together
20
E/R examples A TEAM HAS many PLAYERS Team Players HAS
21
E/R Examples A Plane-Flight transports many Passengers Plane-Fight Passengers Transports
22
E/R Examples A House is Owned by 1 Owner House Owner Owned
23
E/R Examples Many Salespeople Sell many Products. Salesperson Product Sell
24
Attribute A property of an Entity It is a distinct characteristic for which data is maintained An Entity must have at least one attribute or it does not exist
25
Attributes Attributes are fields They describe the entity They can be data attributes (non-key) or key attributes
26
Keys Primary Key – An attribute or group of attributes that has been chosen as the unique identifier of the entity Primary Key Attribute – A attribute that, either by itself or in combination with other primary key attributes will form the primary key Non-key Attribute – An attribute that has not been chosen as a part of the primary key of the entity Candidate Key – An attribute or group of attributes that might be chosen as a primary key Foreign Key – Primary Key from another entity, contributed by a relationship.
27
Key Selection Employee Employee Number Employee Name Employee Sex Employee Hire Date Social Security Number Employee Birth Date Employee Bonus Amount
28
Key Selection Rules Find an attribute that will not change its value of the life of each entity instance Look for a reasonably small key Avoid ‘ Intelligent ’ keys where the structure of the key indicates groupings, locations, classification, dates, etc. Consider substituting a single attribute surrogate key for a large composite key
29
Entities with Attributes Employee Employee Number Employee Name Employee Sex Employee Hire Date Social Security Number Employee Birth Date Employee Bonus Amount Primary Key Area Data Attribute Area
30
Identity Relationship A relationship in which the primary key of the parent entity becomes part of the primary key of the child entity
31
Identity Relationships ParentChild Parent Key Parent Key (fk) Child Key
32
Non-Identity Relationship A relationship where the primary key of the parent entity is placed in the data area of the child entity. In non-identifying relationships the child may be existence-dependent on the parent, but is not identification- dependent on the parent.
33
Non Identifying Relationship ParentChild Parent Key Child Key Parent Key (fk)
34
Entities Independent Entity – An entity that does not depend on any other for its identification. Represented by a square cornered box. Dependent Entity – An entity that depends on one or more other entities for its identification. Represented by a rounded corner box.
35
1:1 Relationships Employee Car Kurt Yugo BrianMustang TonyaRanger ScottJeep NancyCamry Assigned
36
1:n Relationships Customer Video Jack Janet Tim Star Wars Monty Python and the Holy Grail Speed Sleepless in Seattle Casablanca Silence of the Lambs Rents
37
N:M Relationships Course Student Sara Jesse Sam Java Programming Accounting I English 101 Physics for Dummies Enrolls In
38
Excercises Try and draw the E/RD ’ s for the following exercises Some exercises may build on what was done in previous exercises.
39
Exercise #1 Customers come into the video store and rent movies. Customers must be in the store system. This system assigns them a unique identifier. When we sign them up we get their name, address, and phone number.
40
Exercise #2 We have many movies in the store. We try and keep a large number of the most popular movies and a smaller number of less popular movies. Each VHS or DVD copy is individually identified. We will rent these copies many times through out the year.
41
Exercise #3 When a movie is rented out, it is due back in three days. We need to know who has the movie rented out.
42
Exercise #4 For each movie, we need to know the name, rating, and rental rate. For each copy of the movie we need to know its general condition and the remaining rentals we will use that copy for.
43
Exercise #5 We have employees at each store. We know the employee ’ s name, address, hire date and salary. These employees are involved in the rental process. We want to know which employee is involved in each rental event.
44
Exercise #6 When a movie is rented, we need to track when the movie was rented, which copy of the movie was rented, what customer rented it, and what employee is involved.
45
What You Should Know What the different kinds of entities are. What the different relationships are. What a primary key is and how to select it. How to draw simple E/RD ’ s.
46
Assignment Review Chapter 5. Make sure you understand how to create the E/RD for the exercises.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.