ENTITY OCCURRENCE DIAGRAMS
Higher Computing Science
ENTITY OCCURRENCE DIAGRAMS
• Entity occurrence diagrams are used to determine the cardinality
between entities.
• The cardinality can be one of three types:
• One-to one (1:1)
• One-to-many(1:m)
• Many-to-many (m:n)
CAR HIRE EXAMPLE
Customer ID Name
C001 James Green
C002 Hassan Shad
C003 Mike Fraser
C004 Anna Richards
Booking Ref Customer ID Registration Date
B3481 C003 BA18 HER 17/04/20
B3489 C002 BE57 GGV 16/05/20
B3490 C004 LC19 HTR 03/01/20
B3524 C002 LD59 HHT 18/03/20
B3537 C001 SK18 UBG 05/03/20
B3562 C003 ST58 PLK 10/04/20
B3563 C002 SK18 UBG 02/04/20
Booking Customer
CAR HIRE EXAMPLE
• Step 1 - Draw the entities
CustomerBooking
Booking Ref Customer ID
B3481 C003
B3489 C002
B3490 C004
B3524 C002
B3537 C001
B3562 C003
B3563 C002
CAR HIRE EXAMPLE
• Step 2 - Add in the primary key from each table row
B348
1B348
9B349
0B352
4B353
7B356
2B356
3
C001
C002
C003
C004
Booking Ref Customer ID
B3481 C003
B3489 C002
B3490 C004
B3524 C002
B3537 C001
B3562 C003
B3563 C002
CustomerBooking
CAR HIRE EXAMPLE
• Step 3 – Map entity relationships by drawing a line between associated
entity occurrences
B348
1B348
9B349
0B352
4B353
7B356
2B356
3
C001
C002
C003
C004
Booking Ref Customer ID
B3481 C003
B3489 C002
B3490 C004
B3524 C002
B3537 C001
B3562 C003
B3563 C002
CustomerBooking
CAR HIRE EXAMPLE
• Step 3 – Map entity relationships by drawing a line between associated
entity occurrences
B348
1B348
9B349
0B352
4B353
7B356
2B356
3
C001
C002
C003
C004
Booking Ref Customer ID
B3481 C003
B3489 C002
B3490 C004
B3524 C002
B3537 C001
B3562 C003
B3563 C002
CustomerBooking
CAR HIRE EXAMPLE
• Step 3 – Map entity relationships by drawing a line between associated
entity occurrences
B348
1B348
9B349
0B352
4B353
7B356
2B356
3
C001
C002
C003
C004
Booking Ref Customer ID
B3481 C003
B3489 C002
B3490 C004
B3524 C002
B3537 C001
B3562 C003
B3563 C002
CustomerBooking
CAR HIRE EXAMPLE
We can tell from the diagram that a booking can only be placed by one
customer, but a customer can place many bookings.
B348
1B348
9B349
0B352
4B353
7B356
2B356
3
C001
C002
C003
C004
CustomerBooking
CAR HIRE EXAMPLE
We can tell from the diagram that a booking can only be placed by one
customer, but a customer can place many bookings.
Booking
places
Customer
One-to-many
relationship
CAPITAL CITIES EXAMPLE
City ID Name
X001 Edinburgh
X002 London
X003 Paris
X004 Berlin
Country ID Name Capital City Language
CY-105 England X002 English
CY-003 France X003 French
CY-006 Scotland X001 English
CY-007 Germany X004 German
Country City
CAPITAL CITIES EXAMPLE
Country ID City ID
CY-105 X002
CY-003 X003
CY-006 X001
CY-007 X004
CY-105
CY-003
CY-006
CY-007
X001
X002
X003
X004
From the diagram, each country has only one capital city, and each capital
city is the capital of only one country.
CityCountry
CAPITAL CITIES EXAMPLE
From the diagram, each country has only one capital city, and each capital
city is the capital of only one country.
City
has the
capitalCountry
One-to-one
relationship

Entity Occurrence Diagrams

  • 1.
  • 2.
    ENTITY OCCURRENCE DIAGRAMS •Entity occurrence diagrams are used to determine the cardinality between entities. • The cardinality can be one of three types: • One-to one (1:1) • One-to-many(1:m) • Many-to-many (m:n)
  • 3.
    CAR HIRE EXAMPLE CustomerID Name C001 James Green C002 Hassan Shad C003 Mike Fraser C004 Anna Richards Booking Ref Customer ID Registration Date B3481 C003 BA18 HER 17/04/20 B3489 C002 BE57 GGV 16/05/20 B3490 C004 LC19 HTR 03/01/20 B3524 C002 LD59 HHT 18/03/20 B3537 C001 SK18 UBG 05/03/20 B3562 C003 ST58 PLK 10/04/20 B3563 C002 SK18 UBG 02/04/20 Booking Customer
  • 4.
    CAR HIRE EXAMPLE •Step 1 - Draw the entities CustomerBooking Booking Ref Customer ID B3481 C003 B3489 C002 B3490 C004 B3524 C002 B3537 C001 B3562 C003 B3563 C002
  • 5.
    CAR HIRE EXAMPLE •Step 2 - Add in the primary key from each table row B348 1B348 9B349 0B352 4B353 7B356 2B356 3 C001 C002 C003 C004 Booking Ref Customer ID B3481 C003 B3489 C002 B3490 C004 B3524 C002 B3537 C001 B3562 C003 B3563 C002 CustomerBooking
  • 6.
    CAR HIRE EXAMPLE •Step 3 – Map entity relationships by drawing a line between associated entity occurrences B348 1B348 9B349 0B352 4B353 7B356 2B356 3 C001 C002 C003 C004 Booking Ref Customer ID B3481 C003 B3489 C002 B3490 C004 B3524 C002 B3537 C001 B3562 C003 B3563 C002 CustomerBooking
  • 7.
    CAR HIRE EXAMPLE •Step 3 – Map entity relationships by drawing a line between associated entity occurrences B348 1B348 9B349 0B352 4B353 7B356 2B356 3 C001 C002 C003 C004 Booking Ref Customer ID B3481 C003 B3489 C002 B3490 C004 B3524 C002 B3537 C001 B3562 C003 B3563 C002 CustomerBooking
  • 8.
    CAR HIRE EXAMPLE •Step 3 – Map entity relationships by drawing a line between associated entity occurrences B348 1B348 9B349 0B352 4B353 7B356 2B356 3 C001 C002 C003 C004 Booking Ref Customer ID B3481 C003 B3489 C002 B3490 C004 B3524 C002 B3537 C001 B3562 C003 B3563 C002 CustomerBooking
  • 9.
    CAR HIRE EXAMPLE Wecan tell from the diagram that a booking can only be placed by one customer, but a customer can place many bookings. B348 1B348 9B349 0B352 4B353 7B356 2B356 3 C001 C002 C003 C004 CustomerBooking
  • 10.
    CAR HIRE EXAMPLE Wecan tell from the diagram that a booking can only be placed by one customer, but a customer can place many bookings. Booking places Customer One-to-many relationship
  • 11.
    CAPITAL CITIES EXAMPLE CityID Name X001 Edinburgh X002 London X003 Paris X004 Berlin Country ID Name Capital City Language CY-105 England X002 English CY-003 France X003 French CY-006 Scotland X001 English CY-007 Germany X004 German Country City
  • 12.
    CAPITAL CITIES EXAMPLE CountryID City ID CY-105 X002 CY-003 X003 CY-006 X001 CY-007 X004 CY-105 CY-003 CY-006 CY-007 X001 X002 X003 X004 From the diagram, each country has only one capital city, and each capital city is the capital of only one country. CityCountry
  • 13.
    CAPITAL CITIES EXAMPLE Fromthe diagram, each country has only one capital city, and each capital city is the capital of only one country. City has the capitalCountry One-to-one relationship