You are on page 1of 8

Introduction / ER-Model Assignments September 23rd 2022

Exercise 1: Given is the following ternary relation:

1 N

Professors

CoursePaper

Here are the legitimate element instances:


 (s1, p1, t1)
 (s1, p2, t2)
 (s2, p1, t1)
 (s3, p3, t1)

2. Note down the 2 examples of illegal element instances (dotted lines).


(s3, p3, t1) – (s3, p4, t1); (s1, p1, t1) – (s1, p1, t3)

3. Explain why the 2 examples (dotted lines) mark illegal instances.


 (s1, p1, t1) – (s1, p1, t3)
A student can only do 1 coursePaper with the same professor
 (s3, p3, t1) – (s3, p4, t1);
A student can do the same coursePaper only for 1 professor.

Exercise 2: Decomposition of Ternary Relations:

EL, ch.3.9.1: Although in general three binary relationships cannot replace a ternary
relationship, they may do so under certain additional constraints.

Let us see whether we can identify such “additional constraints”, that allow for a lossless
decomposition of a ternary relationship into binary relationships.

Given is the following ternary relationship:

Consider the ternary relationship R(professor, student,Ph_D_thesis) with cardinality 1:1:1 .


Also given is the imposed binary constraint of M:1 between student and professor. (One
professor can supervise many Ph.D.students but one Ph.D. student has only one professor as
supervisor.)

How can you decompose this ternary relationship with the cardinality of 1:1:1 and the given
additional binary constraint M:1 into binary relationships – without semantic loss.

Draw the corresponding binary relationships model!


Mapping this model into a relational schema just leaves the 3 entity relations.

Additional Reading: Journal of Database Management, April-June, 2000, pp. 12 – 19,


https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.28.4274&rep=rep1&type=pdf

Exercise 3:

Given is the following ER model:

• What is the key of the weak entity?


exam {[stud_id:int, exam_part:int, grade: enum]}
 What is sematic meaning of the total participation?
No exam without the Owner student
 What does the N:M relationship “holds” mean?
Multiple professors can hold the exam, each professor can hold multiple exams
 What semantic difference would it make if the attribute “grade” belonged to the
relationship “holds“ instead of the entity “exam”?
Each in an exam involved professor can give a grade – for his part of the exam. So, there
are multiple partial grades. The grade attribute with the entity exam holds the
consolidated grade for the exam in total.
Exercise 4: SportsClub ER Model

4.1 Add the following requirement to your SportsClub ER-model

 A trainer can also be a member of the club, enroll in courses and have his / her minor
children in the club. A trainer does not need to be a member of the club.
 The database also keeps track of the date, a trainer started to hold courses.

Draw this requirement into your model.

4 Add the following (min, max) notations to your SportsClub ERR-Model:

• Each area is headed by exactly one trainer. A trainer can head at most one area

• Each course needs to have a minimum of 5 enrolled members and a maximum of 20


enrolled members.

• Members do not need to enroll in courses but they can enroll in as many courses
they like.

• Each course is taught by exactly one trainer. A trainer can teach up to 10 courses. He
can also currently not teach a course at all.
Exercise 5: Room Reservation ER Model

Add the following (min, max) cardinalities to your Room Reservation ER-Model:

• A maximum of 4 people sit in an office. Every employee sits in exactly one office.

employee (1,1) – works_in - office (0,4) or (1,4) - we do not know if empty offices are
allowed.

• A department has at least 5 employees. Each employee belongs to exactly one


department.

department (5, *) - has -- employee (1,1)

• There is exactly one department head per department. Not all employees are
department heads.

employee (0,1) - heads – department (1,1)

• All parking spaces are assigned but not every employee has a parking space.

employee (0,1) – has – parking_space (1,1)

Exercise 6: ER-Model “Internet Forums on IT Topics”


(Last year’s midterm task)

The company “Internet Community Help” wants to manage their internet forums with a database.
The database needs to fulfill the following semantical requirements:

1. The database keeps track of the different forums. Each forum is stored with forumID, title and a
description of the forum topic. Forums contain posts.
2. Each post for each forum is stored with an increasing ID number, a title, the date it was written
and, of course, the text or content.
3. A post can have responses. The responses to a post are also posts and have the same attributes
as posts without responses.
4. The database keeps track of the users that work with the forums. For each user, the database
keeps track of the username and the user email. Users are allowed to describe themselves and
their skills in a separate field.
5. Users that want to participate need to register with each of the forums they want to use. The
database stores the date of the respective registration.
6. Users can write posts for the forums they are registered. They can also like posts. The database
stores the date when a user writes a post or “likes” a post.
7. Some of the users are moderators. Each forum is headed by a moderator. A moderator can only
head one forum.
1. Develop the corresponding ER-model, with entities, relationships and attributes.
2. Underline keys.
1. Write standard cardinalities for all relationships.
2. Add the following (min,max) cardinalities:
a. Each user has to register with at least one forum. A forum needs to have at least 10
users.
b. A moderator can only head one forum. Each forum is headed by exactly one moderator.
c. A forum must not have more than 200 posts. Each post belongs to exactly one forum.
d. A post may have at the most 10 responses. It does not need to have a response.

Expected Result Points

Correct entities (forum, post, user) with attributes. Minus if there are more entities that do not 1
make sense / do not have attributes / are not needed.

Post as weak entity to forum. 1


Correct recursive relationship response at entity post 1

Correct relationships between user and forum: register and head. Attribute “date of registration” 2
directly at the relationship register

Correct relationships between user and post: write and like. Attribute “date of like” directly at the 2
relationship “like”

Keys – identifies and underlined 1

Standard cardinalities correct


recursive: 1:N – with correct roles (!) 1
2 x 1:N 1
2 x N:M 1
1x 1:1 1

(min,max) cardinalities correct 4

Total (without bonus point) 16

Exercise 7:

Map the exam ER model into the corresponding relations’ scheme. Underline PKs and mark
FKs. How many final relations do you get?

Student: {[stud_id:int]}
Exam: {[stud_id:int, exam_part:int, grade: enum]}
Professor: {[prof_id:int]}
Examination: {stud_id:int, exam_part:int, prof_id:int]}
Exercise 8:

Map the university ER model into the corresponding relations’ scheme. Underline PKs and
mark FKs. How many final relations do you get?

student: {[student_id:int, name:string, semester:int]}

course: {[course_id: int, ECTS:int, title: string, prof_id]}

professor: {[pers_id: int, name:string, rank:string, room: string]}

assistant: {[pers_id: int, name:string, research:string,prof_id:int]}

enrollment {[student_id:int, course_id: int]}

requirement {[predecessor:int, successor:int]}

examination: {[ student_id:int, course_id:int, prof_id: int,grade:string]}

You might also like