DBS201: Entity Relationship Diagram
DBS201: Entity Relationship Diagram
Lecture 3
Agenda
Shows entities similar to a table structure An entity is an object that exists and is distinguishable from other objects An entity is represented by a set of attributes An attribute has a domain (i.e. a set of permitted values) Entities are associated by relationships
Sample ERD
Entity Name Primary key notation
Relationships
1:1 relationship
1:M relationship
M:N relationships
Relationships
1:1 Relationship
One entity can be related to only one other entity, and vice versa Often means that entity components were not defined properly Could indicate that two entities actually should be one entity Sometimes 1:1 relationships are appropriate
Relationships
Relationships
1:M Relationship
One instance of an entity A can be related to zero or more of entity B and one instance of a entity B can be related to only 1 instance of an entity A. Natural type of relationship very common
Relationships
Relationships
M:N Relationship
Can be implemented by breaking it up to produce a set of 1:M relationships a composite or bridge entity which converts an M:N relationship into two 1:M relationships Additional attributes may be assigned as needed
Relationships
Agenda
Discovering Entities
Remember requirements gathering approaches? Different approaches: bottom-up/top-down Top-down uses an overview/narrative of a system to discover entities Bottom-up uses screen/report samples to discover attributes, then these are grouped into entities
Discovering Entities
Top-down:
Given an overview (narrative) of system functionality, compile a list of major entities the system needs to know about An entity is anything such as a person, place, thing or event about which data are to be collected and stored Ignore the characteristics of those things i.e. if you know you need data about a customer, ignore name, date of birth (for now)
Discovering Entities
Top-down Example:
Discovering Entities
Discovering Entities
Top-down Example:
Multiple Real Estate Listing Service (MRELS) is a company that has offices throughout Southern Ontario. These offices have a number of Real Estate agents working for them. MRELS deals in both residential and commercial real estate. Agents work with customers to get a listing or to find a listing for a customer. A listing will include the address and the type of property (residential or commercial), square footage, annual taxes and closing date. If it is a residential property, it will include number of bedrooms, number of bathrooms, special features (central air, heated by gas or oil, radiators or forced air, for instance). For a commercial property, it will include number of offices as well as number of docking bays (where trucks back up to be loaded/unloaded).