• Keine Ergebnisse gefunden

q Relational Databases 1 Exercise Sheet 9: SQL 2 (until Thursday, 12.01.2017) (20 points)

N/A
N/A
Protected

Academic year: 2021

Aktie "q Relational Databases 1 Exercise Sheet 9: SQL 2 (until Thursday, 12.01.2017) (20 points)"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

q Relational Databases 1

Exercise Sheet 9: SQL 2 (until Thursday, 12.01.2017) (20 points)

Please note: you need 50% of all exercise points to receive the Studienleistung for this lecture. In order to pass the RDB I Module, you need both the Studienleistung and you need to pass the exam.

Exercises have to be turned in until Thursday before the lecture either in the lecture hall or into our mailbox at the IFIS floor (Mühlenpfordtstraße 23, 2

nd

floor). Please do not forget your Matrike- lnummer and your tutorial group number on your solutions. If you forget to write your Matrike- lnummer and/or your tutorial group number, you get automatically 0 points. Your solutions may be in German or English. Unless otherwise specified: Always use your own words!

Exercise 9.1 (14 points)

Following conceptual schema describes a simple company database.

Employee Project

Ticket Department

assigned to

works manages works on

in

(1,1) (0,*) (0,*)

(1,1) (0,*)

(0,3) (0,*)

(0,*)

(0,*) start

end

empNr name

phone nr

house

nr budget title description

importance nr

name description

The company is divided into several departments. Each department is uniquely defined by a combina-

tion of a letter and a number, where the letter describes the room (e.g. Department C-15 for room

'C', and number 15). Furthermore, each department is managed by an employee. Each employee is

assigned to a department and to several projects to work on, where the number of projects an em-

ployee works on must not exceed 3. In order to manage the tasks belonging to a project more effi-

ciently, employees are allowed to create tickets for the project. Each ticket has a number, which is

only unique within the scope of the project. It also has a title and description as well as an importance

level which can take the values 'minor', 'medium' and 'major'. When an employee starts to work on

the ticket the start date will be stored and as soon as the task described in the ticket is done, the end

time is stored. Consequently, the ticked is assumed to be closed. Based on the given conceptual

schema, please provide SQL statements to create the tables described in the schema. The created

tables should consider as much constraints as possible.

(2)

Exercise 9.2 (6 points)

Consider the following schema of a network of authors of scientific research papers used last week:

Author (id, name, numberOfPublications) Collaborator (id1 → Author, id2 → Author) Cites (id1 → Author, id2 → Author)

a. Provide a SQL query that finds the names and the ids of the authors that directly or indirectly cites Tilo. (3 points)

b. Provide a SQL query that finds the median of the number of publications. Assume you have an odd number of authors in the table author. Hint: The median

1

of a finite list of numbers can be found by arranging all the numbers from smallest to greatest. If there is an odd number of num- bers, the middle one is picked. For example, consider the set of numbers: 1, 3, 3, 6, 7, 8, 9. this set contains seven numbers. The median is the fourth of them, which is 6. (3 points)

1

https://en.wikipedia.org/wiki/Median

Referenzen

ÄHNLICHE DOKUMENTE

Decide whether the following statements are (1) always false, (2) always true, or (3) true in some cases but false in others. Please, explain your answers. a) The number of

We are also interested in storing the number of cups that can be prepared in the lifetime of the coffee machine. Integrate both models into a

Exercises have to be turned in until Thursday before the lecture either in the lecture hall or into our mailbox at the IFIS floor (Mühlenpfordtstraße 23, 2 nd floor). Please do

If you forget to write your Matrike- lnummer and/or your tutorial group number, you get automatically 0 points.. Your solutions may be in German

actor(person → Person, movie → Movie, role) director(person → Person, movie → Movie) reviewer(person → Person, movie → Movie, stars) hasGenre(movie → Movie, genre

Consider the following schema of a network of authors of scientific research papers Author (id, name, numberOfPublications).. Collaborator (id1 → Author, id2 → Author) Cites (id1

Exercises have to be turned in until Thursday before the lecture either in the lecture hall or into our mailbox at the IFIS floor (Mühlenpfordtstraße 23, 2 nd floor)..

If you forget to write your Matrike- lnummer and/or your tutorial group number, you get automatically 0 points!. Your solutions may be in German