Database Management System - Chapter 9: Advanced Query Formulation with SQL- Part 2

Before beginning the animation, let's examine a SELECT statement containing a Type II nested query. Execution model of the Type II Nested query: - More complex execution model: nested loops - Nested query executes one time for each row in the outer query Example query: - Retrieve faculty who are not students - Type II nested query implementation of a difference problem - Set of all faculty MINUS Set of Faculty who are students - Result: set of faculty who are not students EXISTS comparison: - True if nested query is not empty (one or more rows); false otherwise - NOT EXISTS: true if nested query is empty

ppt6 trang | Chia sẻ: candy98 | Lượt xem: 563 | Lượt tải: 0download
Bạn đang xem nội dung tài liệu Database Management System - Chapter 9: Advanced Query Formulation with SQL- Part 2, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
Chapter 9 Supplemental SlidesType II Nested Query Demonstration Type II Nested Query AnimationSELECT FacSSN, FacLastName, FacDept FROM Faculty WHERE NOT EXISTS ( SELECT * FROM Student WHERE Student.StdSSN = Faculty.FacSSN ) Type II Nested Query AnimationFacultyStudent Type II Nested Query AnimationFacSSN FacLastName FacRank 098-76-5432VINCEASST FacultyStudentResult Type II Nested Query AnimationFacSSN FacLastName FacRank 098-76-5432 VINCE ASST 543-21-0987EMMANUELPROF FacultyStudentResult Type II Nested Query AnimationFacultyStudentResult