retagged by
27,269 views
39 votes
39 votes

A relational database contains two tables Student and Performance as shown below:

$$\overset{\text{Table: student}}{\begin{array}{|l|l|} \hline \text{Roll_no} & \text{Student_name}\\\hline 1 & \text{Amit} \\\hline 2 & \text{Priya} \\\hline 3 & \text{Vinit} \\\hline 4 & \text{Rohan} \\\hline 5 & \text{Smita} \\\hline \end{array}} \qquad\overset{\text{Table: Performance}}{\begin{array}{|l|l|l|} \hline \text{Roll_no} & \text{Subject_code} & \text{Marks}\\\hline 1 & \text{A} & 86 \\\hline 1 & \text{B} & 95 \\\hline 1 & \text{C} & 90 \\\hline 2 & \text{A} & 89 \\\hline 2 & \text{C} & 92 \\\hline 3 & \text{C} & 80 \\\hline \end{array}}$$

The primary key of the Student table is Roll_no. For the performance table, the columns Roll_no. and Subject_code together form the primary key. Consider the SQL query given below:

SELECT S.Student_name, sum(P.Marks) 
FROM Student S, Performance P 
WHERE P.Marks >84 
GROUP BY S.Student_name;

The number of rows returned by the above SQL query is ________

retagged by

5 Answers

Best answer
46 votes
46 votes
Group by Student_name $\implies$ number of distinct values of Student_name

in the instance of the relation all rows have distinct name then it should results $5$ tuples !
edited by
26 votes
26 votes
5 rows

Comma by default means cross product not natural join
14 votes
14 votes
Remember this basic rule in sql

SELECT= PROJECTION

FROM= CROSS PRODUCT

WHERE= SELECT CONDITION

here in the given query we need to take cross product which returns 25 query with keeping in mind the condition to jave marks > 84 so when we group by our answer would be

Amit 452

Priya 452

Vinit 452

Roshan 452

Smita 452

So 5 tuples
4 votes
4 votes
was it 5 I don't remember exactly. But relation Algebra was 1
Answer:

Related questions

32 votes
32 votes
2 answers
1
Arjun asked Feb 7, 2019
14,164 views
Consider the following relations $P(X,Y,Z), Q(X,Y,T)$ and $R(Y,V)$.$$\overset{\textbf{Table: P}}{\begin{array}{|l|l|l|} \hline \textbf{X} & \textbf{Y} & \textbf{Z} \\\hli...
9 votes
9 votes
2 answers
2
admin asked Feb 15, 2023
7,267 views
Consider the following table named $\text{Student}$ in a relational database. The primary key of this table is $\text{rollNum}.$$\text{Student}$$\begin{array}{|c|l|c|c|}\...
40 votes
40 votes
4 answers
4