Frage

We have the following schema:

instructor(ID, name, dept name, salary)
teaches(ID, course id, sec id, semester, year)

Find instructors who taught the most courses in 2009. Can someone please help me? I'm confused how to write this out in relational algebra.

War es hilfreich?

Lösung

This must be homework ;-) So I'll give you some hints...

Since I haven't done tuple relational calculus since college (http://en.wikipedia.org/wiki/Relational_algebra), here is an approximation in sql,

select instructor.ID, instructor.name, count(teaches.ID)
from instructor
join teaches on teaches.ID = instructor.ID
and count(teaches.ID) >= ...
group by ...

Leaving you to fill in the group by and >= values.

Think about how you calculate how many courses each teacher teaches,

select teaches.ID, count(*)
from teaches
group by teaches.ID

This might help: MySQL count maximum number of rows

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top