Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



Use the following schema of the academic institution relational database:

student (rollno, name, degree, year, sex, deptno, advisor)

department (deptid, name, hod, phone)

professor (empid, name, sex, startyear, deptno, phone)

course (courseid cname, credits, deptno)

enrollment (rollno, courseid, sem, year, grade)

teaching (empid, courseid, sem, year, classroom)

prerequisite (precourseid, courseid)

deptno is foreign key in the student, professor and course relations referring to deptid of department relation; advisor is a foreign key in the student relation referring to empid of professor relation; hod is a foreign key in the department relation referring to empid of professor relation; rollno is a foreign key in the enrollment relation referring to rollno of student relation; courseid is a foreign key in the enrollment, teaching relations referring to courseid of course relation; empid is a foreign key of the teaching relation referring to empid of professor relation; precourseid and courseid are foreign keys in the prerequisite relation referring to courseid of the course relation;

Which of the following queries would compute, for each department, the total credits of all the courses offered by the department?






Solution

We need total credits of courses for each department.

So, we must use:

sum(credits)

Also, department and course must be joined using:

deptid = deptno

Then grouping must be done department-wise using:

group by deptid, name

Option (a) correctly uses join, sum and group by.

Option (b) uses count(credits), so it counts courses, not total credits.

Option (c) is syntactically incorrect.

Option (d) uses the join condition in having instead of where, so it is not the correct standard query.



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...