I know I can get the student numbers (snum) of those not enrolled like this:
π snum Students - π snum Enrolled
But I’m stuck on how to get their actual names (sname) instead of just their numbers. Any ideas on how to do this? I’m new to relational algebra, so a simple explanation would be super helpful. Thanks!
Your approach is on the right track, Luke. To get the student names, you’ll need to combine your initial set difference with a join operation. Here’s how you can do it:
This operation first finds the student numbers not in Enrolled, then joins that result with the Students table to retrieve the corresponding names. The outer projection (π sname) ensures you only get the names in your final output.
Remember, the natural join (⨝) automatically matches on the common attribute (snum in this case). This method should give you a list of names for students not registered in any classes. Let me know if you need any clarification on this!