Since this is homework and you basically need to read & work through a textbook's absolutely introductory text & exercises on relational model basics & the relational algebra, I give some guiding questions tailored to your assignment.
A relation (given or query result) comes with a predicate, ie a statement template parameterized by attributes. A relation holds the tuples that make a true statement from its predicate. PKs & FKs are not needed for querying.
What is a relation expression for the tuples where...
the person identified by teacherid teaches the course identified by cid, which is named name? (Answer: Course.)
teacherid teaches cid named name? (Same answer. Why?)
teacherid teaches cid AND cid is named name? (Same answer. Why?)
(We can infer from your assignment query that the Course & Teacher predicates refer to persons or you couldn't get at teacher names.)
t teaches c named n?
t teaches c named n AND c = 101?
t teaches c named n AND t occupies o?
t teaches some course named some name?
for some c, t teaches c named some name? (Same answer. Why?)
for some c, t teaches c named something AND c = 101? (Why do we need FOR SOME?)
i ids a student AND NOT i takes some course taught by some teacher?
some student takes some course taught by t OR t occupies some office?
Thus: We compose a query predicate for the tuples we want using logic operators and the given predicates. Then we get an expression that calculates them by converting logic operators to relation operators and given predicates to given relations. (It can be tedious rearranging to get two relations with the same attributes in order to use AND NOT (MINUS) or OR (UNION).)
See this.
retrieve the Names of teachers who teach more than 1 course
You want tuples where attribute Name is the name of a person and for some two values the person teaches the first one's course and they teach the second one's course and those values/courses are not the same.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…