Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For a given quarter, the table Student lists all students registered at the University, the table Course lists all courses offered, and the table Enrollment

For a given quarter, the table Student lists all students registered at the University, the table Course lists all courses offered, and the table Enrollment encodes the students that attend any course in the current quarter.

Student (Sid, Sname)

Course (Cid, Cname)

Enrollment (Cid,Sid)

primary key is Student (Sid),Course(Cid),Enrollment(Cid,Sid)

Note: a primary key is underlined and a foreign key is italic.

1. A classmate of a student is another student who is enrolled in at least one same class. Write a SQL query that returns all students with all of their classmates. You should return their student IDs, as their names do not uniquely identify them. (5 points)

2. Write a SQL query that computes for each student id in the Student table the total number of different classmates that this student has across all courses. Note that a student may be so busy with research (or parties :-)) that he or she may choose not to enroll to any course that quarter, and hence has no classmates. Such students should still appear in the result, with 0 as the number of their classmates. (5 points)

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

Step: 3

blur-text-image

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago

Question

Methods of Delivery Guidelines for

Answered: 1 week ago