180 views

1 Answer

1 votes
1 votes
“NOT EXIST” simply returns true if there is no tuple exist after the subquery evaluation.

Since we are using S.RollNo in the subquery that means that is corelated subquery.

First from outer query, Each student roll no from student relation go one by one into subquery for verification.

Let’s understand what is the subquery wants to say:

Select P.Pcode from Packages P  → this basically returns the relation which contains one attribute of P.Pcode with tuples of all Pcode values from package relation.  ------------ Relation 1

Select R.Pcode from Registers R where R.RollNo = S.RollNo → here first we check the where condition so when S.RollNo from student will be taken and it will be mapped to all R.RollNo and if they are same or equal then just we note down the Pcode from Registers table correspond to that tuple  and put in the relation which have one attribute known as “R.Pcode”. ------------- Relation 2

Relation 1 minus Relation 2 from this operation we get a result of relation containing those Pcode value which is not mapped with the student whose Rollno had been forwarded to subquery for verification, and if gives empty relation that means all Pcode from Packages are in the Register table with the same Rollno and we know that empty relation makes “NOT EXIST” true so in short our where condition of outer query become true and at the output part that rollno will get shown.

So finally here we are getting roll no of those students who are enrolled in all packages.

Related questions

0 votes
0 votes
0 answers
1
worst_engineer asked Jan 7, 2016
562 views