0% found this document useful (0 votes)
104 views

Sample Paper For The Exam

The document provides 3 sample questions to test SQL skills, asking the student to write queries to return astronauts who died between 1960 and 1970, missions launched before 1990 by the spacecraft Columbia, and rewriting the second query using a cross product join instead of a natural join. Sample correct SQL queries are provided as suggested answers to the 3 questions testing selection of data from the NASA database tables.

Uploaded by

Tyra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views

Sample Paper For The Exam

The document provides 3 sample questions to test SQL skills, asking the student to write queries to return astronauts who died between 1960 and 1970, missions launched before 1990 by the spacecraft Columbia, and rewriting the second query using a cross product join instead of a natural join. Sample correct SQL queries are provided as suggested answers to the 3 questions testing selection of data from the NASA database tables.

Uploaded by

Tyra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Author : Sri Madhisetty.

SAMPLE TEST1
Try this in the lab during your tutorial time, you will get a similar paper in the exam.

Student Number :
Student Name:
(Please write the query you have typed at the back of this page and submit this paper to
your examiner. If you don’t write your student no and student name your paper will not be
checked.
Use the DB at … http://www-staff.it.uts.edu.au/~raymond/db/nasa2.txt
Question 1.
List all astronauts names, year of death, and age at year of death (astroname, death, death-
birth) who died during or after 1960 and before 1970. Order by year of death. With the given
data, the result of the (correct) query will be:

astroname | death | age ç re-naming this


-------------------+-------+----- column is
Chaffee, Roger | 1967 | 32 optional
Grissom, Gus | 1967 | 41
White, Edward | 1967 | 37
Komarov, Vladimir | 1967 | 40
Gagarin, Yuri | 1968 | 34
(5 rows)
Question 2.
List the missions (projectname, missionno) and launchYear of all missions launched before
1990 by any spacecraft called “Columbia”. Order by the launch year. With the given data, the
result of the (correct) query will be:

projectname | missionno | launchyear


-------------+-----------+------------
Apollo | 11 | 1969
Shuttle | STS-1 | 1981
Shuttle | STS-2 | 1981
Shuttle | STS-3 | 1982
Shuttle | STS-4 | 1982
Shuttle | STS-5 | 1982
Shuttle | STS-9 | 1983
Shuttle | STS-61C | 1986
Shuttle | STS-28 | 1989
(9 rows)

Question 3.
Re-express the above natural join query as a cross product
Suggested Answers
Answer 1:
select astroname, death, death-birth
from NASA2_astronaut
where death >= 1960 and death < 1970
order by death;

Answer 2:
select distinct projectname, missionno, launchYear
from NASA2_Mission natural join NASA2_Spacecraft
where Craftname = 'Columbia' and launchYear < 1990
order by launchYear;

Answer 3:
select NASA2_Mission.projectname, NASA2_Mission.missionno, launchYear
from NASA2_Mission, NASA2_Spacecraft
where NASA2_Mission.projectname = NASA2_Spacecraft.projectname
and NASA2_Mission.missionno = NASA2_Spacecraft.missionno
and Craftname = 'Columbia' and launchYear < 1990
order by launchYear;

You don’t have to use “NASA2_Mission” in the “select” part. You could use
“NASA2_Spacecraft” instead.

You might also like