IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob...

17
IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure [email protected] www.robgleasure.com

Transcript of IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob...

Page 1: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

IS6145 Database Analysis and DesignLecture 4: Fine-Granular Design-Specific ER ModellingRob Gleasure

[email protected]

Page 2: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

IS6145

Today’s session The Fine-Granular Design-Specific ER Model Some exercises

Page 3: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

The Fine-Granular Design-Specific ER Model The development of the coarse-granular design-specific ER model

from the Presentation Layer ER model allows greater detail in data modelling.

However it may still contain constructs that may not be mapped directly to the database

Page 4: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

The Fine-Granular Design-Specific ER Model This involves the following tasks

The ER constructs that are not compatible for logical model mapping are decomposed, namely Multi-valued attributes m:n cardinality constraints

Additional attribute characteristics are mapped to the ER diagram

Page 5: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Resolving Multi-Valued Attributes This can be done in two ways

1. Including the attribute as part of the unique identifier for theentity

Image from Data Modeling and Database Design, By Narayan Umanath, Richard Scamell

Page 6: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Resolving Multi-Valued Attributes Which looks as follows in terms of actual database tables

Image from Data Modeling and Database Design, By Narayan Umanath, Richard Scamell

Page 7: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Resolving Multi-Valued Attributes

2. Transform the multi-valued attribute into a new weak entity type (this is usually a last resort)

Image from Data Modeling and Database Design, By Narayan Umanath, Richard Scamell

Page 8: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Resolving Multi-Valued Attributes Which looks as follows in terms of actual database tables

Image from Data Modeling and Database Design, By Narayan Umanath, Richard Scamell

Page 9: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Resolving m:n Cardinality Constraints This requires the addition of a weak entity type with two identifying

parents, sometimes called a ‘Gerund’ entity type, more often referred to as an associative entity

E.g. imagine we added the following relationship to our ERD for Mary’s Playschool

Teacher AssistantHas

favourite

(1, m) (1, n)

Page 10: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Resolving m:n Cardinality Constraints

This could be replaced by

Teacher Assistant

Favours(1, 1) (1,1)

FavoursFavoured pairing

(1, m) (1, m)

Page 11: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Adding Additional Data Characteristics to the ERD Next we want to include the data type and size into the ERD

directly. We do this using a two-part notation.

The first part uses the following letters to indicate type A – Alphabetic N – Numeric X – Alphanumeric Dt - Date

The second part indicates size with a n1.n2 notation n1 indicates the number of characters before a decimal point n2 (optional) indicates the number of places after

Page 12: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Adding Additional Data Characteristics to the ERD For example

Image from Data Modeling and Database Design, By Narayan Umanath, Richard Scamell

Page 13: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Semantic Integrity Constraints The remaining constraints at this level typically specify a range

using the keyword ‘IN’ or ‘NOT’ e.g. > Constraint Experience IN (‘1’,’2’,’3’)

> Constraint Teacher.Age NOT > 67

Others may relate to interdependencies between entities using ‘COUNT’ e.g. > Constraint Teacher COUNT (NOT > 2)

Or more complex interdependencies between entities using ‘related_how’ e.g. >Constraint related_how IN (‘Experience’,’1’,’2’)

NOT (‘Capacity’>’20’)

Page 14: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Example narrative: Mary’s Playschool A parent registers their child or children at the school with a special

registration form, which records the parent, the child, a contact phone number, and any special needs, allergies, etc. the child has. A parent submits one registration form for each child but they may have more than one child at the school. Each room in the school is assigned an age group. Children under 4 years of age go in different rooms from children over 4. A child is assigned to a room based on their age and the capacity of the room. This capacity depends on the room’s size and the experience of the teacher (which may be low, intermediate, or high) but total room capacity capped at 30. A room may be assigned one or more teachers but a teacher must only be assigned to one room. The school also employs assistants to help the teachers (they tend to have favourites they pair up with repeatedly), who must also be assigned to exactly one room. At all times, each room must have an assistant and/or a teacher associated with it. Some part-time teachers also act as assistants on free days.

Page 15: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Example narrative: Mary’s Playschool Draw a Fine-granular design-specific ERD

Jot down any semantic integrity constraints you can think of (don’t worry too much about these though)

Page 16: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Example narrative: BigArt Galleries Galleries keep information about artists, their name (which is

unique), birthplace, age, and one or more styles of art. For each piece of artwork, the artist, the year it was made, its unique title, its type of art (e.g., painting, lithograph, sculpture, photograph), and its price must be stored. Pieces of artwork are also classified into groups of various kinds, for example, portraits, still lifes, etc., and assigned a curator. A given piece may belong to more than one group.

Each group is identified by a name (like those just given) that describes the group. Finally, galleries keep information about customers. For each customer, galleries keep that person’s unique name, address, total amount of dollars spent in the gallery (very important!), and the artists and groups of art that the customer tends to like.

Page 17: IS6145 Database Analysis and Design Lecture 4: Fine-Granular Design-Specific ER Modelling Rob Gleasure R.Gleasure@ucc.ie .

Example narrative: BigArt Galleries Draw a Fine-granular design-specific ERD

Jot down any semantic integrity constraints you can think of (again, don’t worry too much about these)