• Keine Ergebnisse gefunden

Relational Databases 1 Exercise Sheet 8: SQL 1 (until Thursday 22.12.2011)

N/A
N/A
Protected

Academic year: 2021

Aktie "Relational Databases 1 Exercise Sheet 8: SQL 1 (until Thursday 22.12.2011)"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Relational Databases 1

Exercise Sheet 8: SQL 1 (until Thursday 22.12.2011)

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! Please always use your own words for all questions.

Database Schema

The following database schema stores information about movies and all participating people. The Movie relation includes an id, the movie title, the year of publication, the country where the movie was produced, its box-office takings, and a type (e.g. cinema or TV). A person is identified by an id, has a name, a sex and a birthdate. The Plays relation contains all actors with their respective roles.

The Crew relation contains people attending in the respective movie, e.g. as a director or producer (type=‟director‟ ,..). Furthermore, each movie is associated with a number of genres in the Has_Genre relation.

Movie (mid, title, year, country, box_office_takings, type) Person (pid, name, sex, birthdate)

Crew(person  Person, movie  Movie, type) Plays (person  Person, movie  Movie, role) Has_Genre(movie  Movie, genre  Genre) Genre(name, description)

Exercise 8.1 (17 points)

Translate the following expressions to SQL.

a) Show a list including all cinema movies. (1 point)

b) Show a list of all genres (name) in whose description the word „hero‟ occurs. (1 point) c) Show the names of all actors playing in any „Fantasy‟ movie in 1980. (2 points)

d) Show a list including the number of movies for each genre. Please note, your list should also include genres having no movies. (2 points)

e) How many female actors played a „killer‟ (role) in a Steven Spielberg (director) movie? (2 points)

f) Show the titles of all movies where „Terence Hill‟ (actor) played without „Bud Spencer‟ (ac- tor). (3 points)

(2)

g) Find the titles of all movies whose box-office takings are higher than the average box-office takings regarding all movies. (3 points)

h) Which actor played in the most movies? (3 points)

Exercise 8.2 (5 points)

a) Explain how the GROUP BY clause works. What is the difference between the WHERE and the HAVING clause? (2 points)

b) What restrictions apply to the use of the aggregate functions within the SELECT statement?

How do NULL values affect the aggregate functions? (2 points)

c) What is the difference between correlated and uncorrelated subqueries? (1 point)

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

Find at least 3 independent, non-trivial functional dependencies that do not conflict with the given data (3 points).. Can you be sure, if the functional dependencies found in

Please note: To pass the “RDB 1 Modul” you need the exercise points and the exam.. Please use your own words for

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