• Keine Ergebnisse gefunden

Relational Databases 1 Exercise Sheet 9: SQL 2 (until Thursday 12.01.2012)

N/A
N/A
Protected

Academic year: 2021

Aktie "Relational Databases 1 Exercise Sheet 9: SQL 2 (until Thursday 12.01.2012)"

Copied!
3
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Relational Databases 1

Exercise Sheet 9: SQL 2 (until Thursday 12.01.2012)

Please note that you need 50% of all exercise points to receive the “Studienleistung”. Exercises have to be turned in until Thursday of each respective week and must be completed in teams of two students each. You may hand in your solutions either on paper before the lecture or into the mailbox at the IFIS floor (Mühlenpfordtstraße 23, 2nd floor). Please do not forget your “Matrikel- nummer” and your tutorial group number on your solutions. Your solutions may be in German or English. Please note: To pass the “RDB 1 Modul” you need the exercise points and the exam!

Exercise 9.1 (10 points)

Translate the following ER-Schema to relational schemata. Write down all necessary SQL statements for creating the respective tables.

 All attributes are Integer values and should not be NULL.

 The statements have to include all primary- and foreign keys.

 Write down which of the modeled integrity constraints are not included in your statements.

(2)

Exercise 9.2 (6 points)

Given the schema of a university database. Explain the consequences of the following operations:

CREATE TABLE students (

matNo INTEGER PRIMARY KEY, name VARCHAR(50) NOT NULL, semester INTEGER)

CREATE TABLE lecture (

lecNo INTEGER PRIMARY KEY, title VARCHAR(50) NOT NULL,

sws INTEGER,

readBy INTEGER REFERENCES professors ON DELETE SET NULL) CREATE TABLE professor (

persNo INTEGER PRIMARY KEY, name VARCHAR(50) NOT NULL, room INTEGER UNIQUE)

CREATE TABLE listen (

matNo INTEGER REFERENCES students ON DELETE CASCADE, lecNo INTEGER REFERENCES lectures ON DELETE CASCADE, PRIMARY KEY (matNo, lectNo))

CREATE TABLE examine (

matNo INTEGER REFERENCES students ON DELETE CASCADE, lecNo INTEGER REFERENCES lectures ON DELETE NO ACTION, persNo INTEGER REFERENCES professors ON DELETE SET NULL, grade DOUBLE CHECK(grade BETWEEN 1.0 and 5.0)

PRIMARY KEY (matNo, lectNo)) Professor

persNo name room

227 Lupack F441

156 Bölke C122

358 Duckstein F142

756 Kant C221

110 Emrich F411

Students

matNo name semester

24123 Kent 6

24001 Hesky 4

24560 Boba 4

Lecture

lecNo title sws readBy

1 RDB1 5 358

2 WDM 4 156

3 SE 4 756

4 RN 5 110

5 DUA 5 227

Examine

matNo lecNo persNo grade

24123 1 358 2.7

24001 2 156 4.0

24560 4 756 1.0

Listen

matNo lecNo

24123 1

24001 1

24123 5

24560 1

24560 4

(3)

a. DELETE FROM lecture where title=’RDB1’;

b. INSERT INTO examine VALUES (24123, 5, 331, 3.0) c. INSERT INTO examine VALUES (24001, 2, 756, 2.0) d. DROP TABLE students;

Merry Christmas

Referenzen

ÄHNLICHE DOKUMENTE

Exercises have to be turned in until Thursday of each respective week and must be completed in teams of two students each.. You may hand in your solutions either on paper before

actor(person → Person, movie → Movie, role) director(person → Person, movie → Movie) hasGenre(movie → Movie, genre → Genre) connection(from → Movie, to → Movie, type)..

Based on this relation schema, please provide statements returning following results in relational algebra, tuple relational calculus and domain relational calculus:.

actor(person → Person, movie → Movie, role) director(person → Person, movie → Movie) hasGenre(movie → Movie, genre → Genre) connection(from → Movie, to → Movie,

Based on the given conceptual schema, please provide SQL statements to create the according tables described in the schema.. The created tables should regard as much

You may hand in your solutions on paper before the lecture or into the mailbox at the IFIS floor (Mühlenpfordtstraße 23, 2nd floor).. Please do not

Translate the following ER-Schemata to relational schemata. Please write down all additional con- straints that are not represented in your relational model.. c).

f) Show a list of all people (name) that includes the number of movies they have participated in as an actor. Of course, the list should also include all people that have