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 8965833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:53:45+00:00 2026-06-15T16:53:45+00:00

I’m having some trouble finding out the proper way to approach this question. Database

  • 0

I’m having some trouble finding out the proper way to approach this question.

Database tables:
Student(stdID[pk], stdName, stdSet)
Enrollment(stdID[pk], crsID[pk], year[pk], semester[pk], grade)
Offering(crsID[pk], year[pk], semester[pk], instrID)
Course(crsID[pk], crsTitle, creditHrs)
Instructor(instrID[pk], instrName, dept)

“Find all instructors who had taught, from 2006 to 2008, a given student A01234567. List the student ID, instructorID, and year. Do not duplicate rows.”

What I originally had was this:

SELECT DISTINCT stdID, instrID, year
FROM Student s
JOIN Instructor i ON Offering o (o.instrID = i.instrID)
JOIN Offering o ON Course c (c.crsID = o.crsID)
WHERE stdID = 'A01234567'
    AND date BETWEEN (2006 AND 2008);

However, this is not entirely correct. I have notes that it’s something to do with “missing 2 columns from Offering join”, but I don’t know what that means…

  • 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-06-15T16:53:46+00:00Added an answer on June 15, 2026 at 4:53 pm

    Conceptually, I would start with the Instructor table, since that’s what I want to return.

    I’d join that to the Offering table, so I have all the Offering for each instructor.

    (But we don’t really need anything from the Instructor table at all, since we have InstrId in the Offering table.)

    Then I’d join that to Enrollment, to basically get all the students that were enrolled in each course offering.

    Then I’d join that to Student. But again, we don’t really need anything from the Student table, we already have stdId in the Enrollment table.

    The tricky part is that join between Offering and Enrollment. The join predicate will need to be on year and semester, as well as crsId.

    So, to satisfy the stated requirements, only two tables need to be queried:

    SELECT e.stdId
         , o.instrId
         , e.year
      FROM Offering o
      JOIN Enrollment e
        ON e.crsId = o.crsId
       AND e.year = o.year
       AND e.semester = o.semester
     WHERE e.stdID = 'A01234567'
       AND e.year >= 2006
       AND e.year <= 2008
     GROUP
        BY e.stdId
         , o.instrId
         , e.year
     ORDER
        BY e.stdId
         , o.instrId
         , e.year
    

    There’s a peculiarity with the database design. Consider what happens when there are two or more instructors teaching a given course in the same year and semester.

    But the student was enrolled in only one of those.

    This query will pick up the instructors of both offerings.

    It’s a problem with the query, but the given database design doesn’t give us any way to resolve the issue… because there’s no way to tell which instructor the student had.

    The query satisfies the stated requirements, but the results will be a bit odd, showing a particular student had six different instructors for ‘Calc I’ in the fall of 2006.

    Unless there’s something that’s eluding me here.

    EDIT:

    As Emily Litella would have intoned, “Never mind…”. There’s a unique constraint on the Offering table. There can be only one offering of a given crsId in a semester. So there’s no problem there. (Except that it’s peculiar that there would be only one offering of a given course in a given semester.)

    The GROUP BY is not necessary. The constraints already guarantee that there will be no duplicate rows returned.

    Actually, I think the GROUP BY is needed, because it’s possible that the student was enrolled in two separate courses led by the same instructor. The purpose of the GROUP BY is to eliminate any duplicate rows from the result set (as indicated in the specification.)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.