Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3314626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:15:18+00:00 2026-05-17T22:15:18+00:00

Here is the schema: Student(Snum, Sname) Course(Cnum, Cname) Prerequisite(Cnum, Prereq) Professor(Pnum,Pname, Dept, Office) Enrollment(Snum,

  • 0

Here is the schema:

Student(Snum, Sname)
Course(Cnum, Cname)
Prerequisite(Cnum, Prereq)
Professor(Pnum,Pname, Dept, Office)
Enrollment(Snum, Cnum, Term, Section, Mark)
Schedule(Cnum, Term, Section, Days, Time, Room)
Class(Cnum, Term, Section, Instructor)

The full question is:

Find professors (Pnum, Pname, Dept)
who whenever taught a course in the
Class relation, either the course does
not have any prerequisite or the
professor has also taught each of the
prerequisites of the course. A
professor taught a course exactly when
the professor taught a class (a
section of a course) in some term.

My starting point so far…

SELECT * FROM Class c
LEFT JOIN Prerequisite p ON p.Cnum = c.Cnum
WHERE p.Cnum IS NULL

I know how to find the courses that the professors taught that have no prerequisites, and therefore they satisfy part of the condition. The next step is finding if they have taught the prerequisites if there are any. Also, my current query only selects a single prerequisite for every class, when there can really be multiple prerequisites for a class.

Note: Cnum and Prereq are both foreign keys to Cnum

Thanks for any help! This is a toughie.

EDIT:
I came up with the final answer!

SELECT prof.Pnum, prof.Pname, prof.Dept FROM Professor prof
WHERE prof.Pnum NOT IN
(
SELECT DISTINCT c.Instructor FROM Class c
RIGHT JOIN Prerequisite p ON p.Cnum = c.Cnum
LEFT JOIN Class cpre ON cpre.Cnum = p.Prereq AND cpre.Instructor = c.Instructor
WHERE cpre.Instructor IS NULL AND c.Instructor IS NOT NULL
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:15:18+00:00Added an answer on May 17, 2026 at 10:15 pm

    Since this is homework, here’s a hint…

    If Professor taught all prerequisites then Pnum does not EXISTS in subselect of Prerequisites for a Class’ Course left joined to actual Classes that Professor taught in given Term where actual class is NULL (in other words where there are no prerequisites for a class taught that was not actually thought).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my schema: Suppliers( sid: integer , sname: string, address string) Parts( pid:
I am using MySQL. Here is my schema: Suppliers( sid: integer , sname: string,
I am using MySQL. Here is my schema: Suppliers( sid: integer , sname: string,
Lets imagine I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm If a customer
Here is my current setup: Database Role - MyDbRole Schema - MySchema User -
The Media Wiki database Schema, here , has taught me a lot. Cannot-understand: In
c#/oop noob here. I am creating a datatable from the schema of a sql
I have a one-to-one relationship but hibernatetool complains when generating the schema. Here's an
Just getting into SQL stored queries right now... anyway, here's my database schema (simplified
I have the following database schema: Here's how I populate a DropDownList in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.