Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. The table Scores(Team, Day, Opponent, Runs) Gives the scores in the Japanese Baseball League for two consecutive days. The Opponent is NULL if the

1. The table

Scores(Team, Day, Opponent, Runs)

Gives the scores in the Japanese Baseball League for two consecutive days. The Opponent is NULL if the Team did not play on that day. The number of Runs is given as NULL if either the team did not play, or will play on that day but the game is not yet concluded. The data in this table is as follows:

Team Day Opponent Runs
Dragons Sunday Swallows 4
Tigers Sunday Bay Stars 9
Carp Sunday NULL NULL
Swallows Sunday Dragons 7
Bay Stars Sunday Tigers 2
Giants Sunday NULL NULL
Dragons Monday Carp NULL
Tigers Monday NULL NULL
Carp Monday Dragons NULL
Swallows Monday Giants 0
Bay Stars Monday NULL NULL
Giants Monday Swallows 5

What is the result of the following query?

 SELECT Opponent, COUNT(*), AVG(Runs) FROM Scores GROUP BY Opponent 

Then, identify in the list below one of the tuples in the result.

a)
Bay Stars 1 9
b)
Dragons 2 3.5
c)
Giants 2 0
d)
Swallows 12 2.667
2. Suppose relations R(A,B) and S(B,C,D) have the tuples shown below:

R =
A B
1 2
3 4
5 6
S =
B C D
2 4 6
4 6 8
4 7 9

Compute the result of the join query:

 SELECT A, R.B, C, D FROM R, S WHERE R.B = S.B 

Then, identify which of the following tuples is in the result.

a) (1,2,6,8)
b) (3,4,7,9)
c) (3,4,4,6)
d) (1,2,4,8)
3. The latest scores from the Japanese Baseball League are in the table with schema

Scores(Team, Opponent, RunsFor, RunsAgainst)

The data in this table is as follows:

Team Opponent RunsFor RunsAgainst
Dragons Tigers 5 3
Carp Swallows 4 6
Bay Stars Giants 2 1
Marines Hawks 5 3
Ham Fighters Buffaloes 1 6
Lions Golden Eagles 8 12
Tigers Dragons 3 5
Swallows Carp 6 4
Giants Bay Stars 1 2
Hawks Marines 3 5
Buffaloes Ham Fighters 6 1
Golden Eagles Lions 12 8

What is the result of executing on this data the query:

 SELECT Team, Opponent FROM Scores WHERE Team LIKE '% %' OR Opponent LIKE '_i%' 

Identify, in the list below, a row of the result.

a)
Marines Hawks
b)
Swallows Carp
c)
Golden Eagles Lions
d)
Buffaloes Ham Fighters
4. Here are two relations, R(A,B) and S(C,D). Their current values are:

R =
A B
1 2
3 4
5 6
7 8
S =
C D
2 10
4 12
6 14
8 16

Compute the result of the query:

 SELECT A, D FROM R, S WHERE B+C = 10 

Identify, in the list below, the row that appears in the result.

a) (3,10) b) (5,14) c) (1,14) d) (1,16)
5. Here are three relations, R(A,B), S(C,D), and T(E,F). Their current values are:

R S T
A B
0 1
1 0
1 1
C D
0 1
1 0
1 1
E F
0 1
1 0
1 1

Compute the result of the query:

 SELECT A, F, SUM(C), SUM(D) FROM R, S, T WHERE B = C AND D = E GROUP BY A, F HAVING COUNT(*) > 1 

Identify, in the list below, the row that appears in the result.

a) (1,0,2,1)
b) (1,0,2,2)
c) (1,1,1,1)
d) (1,0,1,2)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions