Hi, Making sure I\'m doing this right: Students(sid:decimal(9,0),sname:char(20),
ID: 3609958 • Letter: H
Question
Hi,Making sure I'm doing this right:
Students(sid:decimal(9,0),sname:char(20), rno:int, major:char(20))
Courses(cid:decimal(9,0),cname:char(20), fid:decimal(9,0), color:char(10), room:char(4))
Enrolled(sid:decimal(9,0),cid:decimal(9,0))
Faculty(fid:decimal(9,0),fname:char(20))
Select the names of courses that do not have a studentcalled ‘Copycat’ enrolled in them.
PROJECTcname (( SELECTcources.cid ( CoursesJOIN Enrolled ) ] JOIN STUDENTS (SELECTsname !='Copycat' ( Students JOIN Enrolled)))
I'm pretty sure this is right, if this was sql I would use the -operator which might simply things.
Students(sid:decimal(9,0),sname:char(20), rno:int, major:char(20))
Courses(cid:decimal(9,0),cname:char(20), fid:decimal(9,0), color:char(10), room:char(4))
Enrolled(sid:decimal(9,0),cid:decimal(9,0))
Faculty(fid:decimal(9,0),fname:char(20))
Select the names of courses that do not have a studentcalled ‘Copycat’ enrolled in them.
PROJECTcname (( SELECTcources.cid ( CoursesJOIN Enrolled ) ] JOIN STUDENTS (SELECTsname !='Copycat' ( Students JOIN Enrolled)))
I'm pretty sure this is right, if this was sql I would use the -operator which might simply things.
Explanation / Answer
Dear, Given relations are, Students(sid:decimal(9,0),sname:char(20), rno:int, major:char(20))Courses(cid:decimal(9,0),cname:char(20), fid:decimal(9,0), color:char(10), room:char(4))
Enrolled(sid:decimal(9,0),cid:decimal(9,0))
Faculty(fid:decimal(9,0),fname:char(20)) Select the names ofcourses that do not have a student called ‘Copycat’enrolled in them. SQL Query: selectcname from Cources where cid in( selectcid from Enrolled where sid in( selectsid from Students where sname!='Copycat')); selectcname from Cources where cid in( selectcid from Enrolled where sid in( selectsid from Students where sname!='Copycat'));
Query in RELATIONALALGEBRA : PROJECTcname([ SELECTcources.cid = enrolled.cid ( Cources X Enrolled) ] JOINenrolled.sid = students.sid[SELECTsname!='Copycat'( Students X Enrolled)]) Here, weare displaying cource names first by making cartesian product ofcources and enrollment with a common field "cid". Next we arejoining the the student and entolled relations with a common field"sid" and retrieving the student names not equal to"Copycat". " I hope this will help you"
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.