COMP3311 Week 1 Tuesday Lecture

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [0/17]
❖ In today's lecture ...


COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [1/17]
❖ Reminders

Using PostgreSQL on  vxdb2 ...

Lectures ... see Lecture Material link
COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [2/17]
❖ ER Model (recap)

ER models give a visual representation of database structure

Primary components

ER models don't capture all information from the scenario

ER models are useful as a step towards an SQL schema

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [3/17]
❖ ER Model (recap) (cont)

ER design elements:

[Diagram:Pics/er-rel/er-symbols.png]

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [4/17]
❖ ER Model (recap) (cont)

Relationships:

[Diagram:Pics/er-rel/cardinal.png]


Thick line = total participation;   thin line = partial participation

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [5/17]
❖ N:M Relationships


[Diagram:Pics/er-rel/relNM.png]

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [6/17]
❖ 1:N Relationships


[Diagram:Pics/er-rel/rel1N.png]

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [7/17]
❖ 1:1 Relationships


[Diagram:Pics/er-rel/rel11.png]

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [8/17]
❖ Class Hierarchies

ER also implements super-class / sub-class hierarchies

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [9/17]
❖ Exercise: Student/Lecturer Class Hierarchy


Modify the minimal ER class hierachy to represent

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [10/17]
❖ Developing ER Models


A complete ER model should ...

There are frequently different kinds of people (⇒ sub-classes)
COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [11/17]
❖ Exercise: Medical Information

Develop an ER model for the following scenario:

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [12/17]
❖ Exercise: Book Publishing Scenario

Develop an ER model for the following scenario:

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [13/17]
❖ Data Models

Entity-relationship (ER) model

Relational model SQL schemas
Also ODL, UML, and a variety of others ... but not in this course.
COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [14/17]
❖ Relational Model

Tuples are collections of values   (cf. Python tuples, C  structs)

Relations are sets of tuples Constraints are logical statements on valid data Tuples correspond to entities

Relations correspond to entity sets and  relationships

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [15/17]
❖ Relational Model (cont)


Different kinds of constraints

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [16/17]
❖ Exercise: ER-to-relational Mapping

Convert this ER model to a relational model

[Diagram:Pics/er-rel/enrolments.png]

COMP3311 22T3 ♢ Week 1 Tuesday Lecture ♢ [17/17]


Produced: 17 Feb 2023