Given the following STUDENT‐COURSE scheme: STUDENT (Rollno, Name, courseno) COURSE (courseno, coursename, capacity), where Rollno is the primary key of relation STUDENT and courseno is the primary key of relation COURSE. Attribute coursename of COURSE takes unique values only. Which of the following query(ies) will find total number of students enrolled in each course, along with its coursename. *
A. SELECT coursename, count( ) 'total' from STUDENT natural join COURSE group by
coursename;
*B. SELECT C.coursename, count( ) 'total' from STUDENT S, COURSE C where
S.courseno=C.courseno group by coursename;
*C. SELECT coursename, count( ) 'total' from COURSE C where courseno in (SELECT courseno
from STUDENT);
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A. A and B only
Explanation
A (natural join) and B (explicit join on courseno) both group by coursename and count. C has no GROUP BY, so it returns one aggregated row (and is invalid with coursename).
More Database Management Systems questions
- Given STUDENT(Rollno, Name, Courseno) and COURSE(Courseno, Coursename, Capacity) with 5 and 3 records, R = STUDENT × COURSE is computed. Ma…
- A B tree indexes a database file with search key 10 bytes, block 1024 bytes, record pointer 9 bytes and block pointer 8 bytes. If K is the…
- Given R(x, y, z, w) with F = {x → y, z → w}, where all attributes are atomic: A. R is in First Normal Form. B. R is in Second Normal Form.…
- A company is consuming parts in the manufacturing of other products. Each of the part is either manufactured within the company or purchase…
- A transaction may be in one of the following states during its execution life cycle in concurrent execution environment. A. FAILED B. TERMI…
- Which of the following is used to create a database schema?