Homework database

Embed Size (px)

Citation preview

  • 8/13/2019 Homework database

    1/2

    Advanced Database Queries Home Work 3 Part 2

    DATABASE SYSTEMS CSY 2013

    SECOND YEAR 2013-2014 SEMESTER-I

    Date of Issue 18th Nov 2013 Date of Submission 25th Nov 2013 (5:00 PM)

    This homework3-part 2 must be done in groups of at most three but the group members must

    be the same as for part-1 of homework 3. Part-3 will be released next week. No submission

    will be accepted after 5:00 PM, 25th November 2013.

    Overview

    In this homework, you will continue to work with the Olympics Database SportsDB.

    Note that there may be some queries that return no tuples as a result; for such queries,we are only interested in the correct formulation of the queries. Hence, do not assume

    that every query returns results, although most of them actually do. List the results of

    your queries if there are ten or less tuples retrieved, otherwise write the number of

    rows retuned along with first ten rows returned by the query execution.

    (a) List the first and last names of all athletes who participated in the track

    competition '3000M Steeplechase Men' and reached the finals.

    (b) List all athletes (last names and first names) who participated in the field

    competition 'Long Jump Women', and reached the finals.

    (c) List full details of those athletes who participated in both a field competition and a

    track competition.

    (d) List the names of athletes from Australia who participated in the competition

    'Marathon Men'.

    (e) Retrieve the name of the country (CName), the fastest woman in the track

    competition W11 comes from. Note that zero time ('000:00:00') is an invalid result.

    (f) Find the name of athlete and the name of the country, where the athlete who

    jumped the longest distance comes from.

    (g) For each field competition, give the competition name and the number of athletes

    who did not reach the finals.

    (h) List all track competitions (all details) for which a new record has been

    established.

    (i) Are there any field competitions with no participants?

    (j) List the countries not having any athletes.

  • 8/13/2019 Homework database

    2/2

    (k) Obtain the difference in distances between the best and worst time of athletes who

    participated in the competition 'Discus Women'. Note that meters equal to 0 should

    not be considered.

    (l) Retrieve those athletes who participated in more than one competition.

    (m) Retrieve those athletes who participated in only one competition and not in more

    than one competition, either field or track.

    DDL Commands and Data Modifications:

    (a) Delete all tuples from the table r_field where meter = 0 and delete all tuples from

    the table r_track where time = '000:00:00'.

    (b) Update the Country table so that correct values for AW and AM are recorded.

    (c) Create a table named shotput with attributes A# (data type number(4)), WM (data

    type char(1)), and meter . Specify the attribute A# as the primary key of the relation.

    Possible values for the attribute WM indicate whether the participant is a man

    (denoted with M) or a woman (denoted with W).

    (d)Use the data stored in the relation r_field to insert all those participants together

    with their times into the relation shotput who participated in the Shot Put competitionand who has positive distance. Make sure to use the correct values for the attribute

    WM to insert into shotput.

    Aggregate Functions and Grouping:

    (a) For each field competition list the name of the competition and the number of

    participants. List only those competitions that have more than 20 participants.

    (b) Give the time of the best athlete with the minimum time in the track competition'3000M Steeplechase Men'. Consider only positive times.

    (c) For each track competition, retrieve the number of athletes who have set up a new

    record.