comp101-lect04
comp101-lect04
comp101-lect04
1:
Foundations
of
Information
Systems
Lecture 4: Stephen
Cranefield
Data Modelling Department of
Information
Science
(II)
Entity-Relationship
Diagrams
Paper Structure
Section 1: Databases
(storing and retrieving You are (still) here
organized information)
Representations
Section 4: Algorithms
(execution of
instructions)
From Lecture 3: Data modelling
• To set up a database, you must first define a
model of the data to be stored in it
• A data model:
• models the types of things (entities) of
interest
• specifies the attributes needed to
describe each entity
• models relationships between entities
• is used by analysts to capture requirements
and inform the design of databases
• An entity-relationship diagram (ERD) is a
common type of data model
Example: recording sales
Entity-relationship diagram (ERD)
Entity (may end up as a table in a database)
} Attributes
(may end up as columns
in a database table)
Relationship
Unique identifier
(primary key).
Can be a
combination of two {
attributes as shown
here
Notes
:
1) Th is u s es t h e “ In fo r m a t io n E n g in e e r in
• T hi s is In fo r m a tio n E ng i n ee rin g n o ta t io n ,
go”n: evaorfimanatnoy fdEifRfeDrenntoEtaRtDionnotations
2) •DaSsohlieddanadnddassohleidd lliinneess
hfoavreresulabttiloyndsifhfeipresnht amveeasnpinegcsif–icwme
weaillniginngosreththaattwineCwOoMnP’t101 discuss
Objectives for today
Employee Product
Customer Location
Transaction Departme
nt
17
How do we tell
whether something is
an entity?
1. Is it a specific type of thing we need to
know about?
Types
Instances
(possibly many instances of a single
entity)
…
Entities vs. Instances/Data items
• Examples:
• A student ID is unique to a specific student
• A sale line needs both the sale number and
product code to identify it uniquely
Notation for unique IDs
• Often shown in a
separate
Student ID
compartment
• Unique ID
(“primary
key”)
• Then other attributes
Example multi-attribute unique ID
• A sale number does not uniquely identify a
sale line There can be multiple sale lines in
the sale
• A product number does not uniquely identify a
sale line The product can appear in multiple
sales
• These two attributes combined uniquely identify a sale line
ERD concept 3: Relationship
• Reflects a real-world association
between entities:
• A sale is to a customer
• A sale is made by an employee
• An employee has an assigned office
• Properties of a relationship:
• Cardinality: one to one, one to many, many to many
• Participation: optional or mandatory
Relationship cardinality
Movie Director
• Director to Movie:
A Director may direct many Movies
(or: a director directs zero or more movies)
Adding details to an M:N
relationship
• Consider the relationship between
patient and illness:
2.
Insert associative entity
• Identify the
following in the ERD
at left:
• Entities
• Attributes
• Unique identifiers
• Relationship(s) where
participation is
mandatory on both
sides
• Describe the
relationship between
Customer and Sale
Header in plain
English
Exercise 2: interpret an ERD