Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع الاساسي للمادة هي الكتاب المعتمد في وصف المقرر
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Slide 6- 2 Database State for COMPANY All examples discussed below refer to the COMPANY database shown here.
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Employee Slide 6- 3
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Department Slide 6- 4
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Project Slide 6- 5
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 1 Find the name and address of all employees who work for the ‘Research‘ department. Slide 6- 6
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 1 Find the name and address of all employees who work for the ‘Research‘ department. Slide 6- 7 FNAMELNAMEAddress JohnSmith731 Fondren, Houston, TX FranklinWong638 Voss, Houston, TX RameshNarayan975 Fire Oak, Humble, TX JoyceEnglish5631 Rice, Houston, TX
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 1 Find the name and address of all employees who work for the ‘Research‘ department. Slide 6- 8 RESEARCH_DEPT DNAME=’Research’ (DEPARTMENT) RESEARCH_EMPS (RESEARCH_DEPT Dnumber= DNO EMPLOYEE) RESULT FNAME, LNAME, ADDRESS (RESEARCH_EMPS)
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 2 For every project located in 'Stafford', list the project number, the controlling department number, and the department manager's last name, address, and birth date Slide 6- 9
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 2 For every project located in 'Stafford', list the project number, the controlling department number, and the department manager's last name, address, and birth date Slide PNUMBERDNUMLNAMEADDRESSBDATE 104Wallace291 Berry, Bellaire, TX20-JUN Wallace291 Berry, Bellaire, TX20-JUN-31
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 2 For every project located in 'Stafford', list the project number, the controlling department number, and the department manager's last name, address, and birth date Slide STAFFORD_PROJS Plocation=’Stafford’ (PROJECT) CONTR_DEPT (STAFFORD_PROJS Dnum = Dnumber DEPARTMENT) PROJ_DEPT_MGR (CONTR_DEPT MgrSSN= SSN EMPLOYEE) RESULT Pnumber, Dnum,Lname, Address,Bdate (PROJ_DEPT_MGR )
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 3 Find the names of all employees who work on all the projects controlled by department number 5. Slide 6- 12
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 3 Find the names of all employees who work on all the projects controlled by department number 5. Results : empty because no tuples satisfy the criteria Slide 6- 13
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 3 Find the names of all employees who work on all the projects controlled by department number 5. Slide DEPT5_PROJS(Pno) Pnumber( Dnum=5 (PROJECT) EMP_PROJ Essn, Pno (WORKS_ON ) RESULT_EMP_SSNS (EMP_PROJ ÷ DEPT5_PROJS) RESULT Lname,Fname (RESULT_EMP_SSNS * EMPLOYEE)
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 4 List the names of employees who have no dependents. Slide 6- 15
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 4 List the names of employees who have no dependents. Slide LNAMEFNAME ZelayaAlicia NarayanRamesh EnglishJoyce JabbarAhmad BorgJames
Copyright © 2011 Ramez Elmasri and Shamkant B. Navathe Query 4 List the names of employees who have no dependents. Slide ALL_EMPS SSN (EMPLOYEE) EMPS_WITH_DEPS ( SSN ) ESSN ( DEPENDENT ) EMPS_WITHOUT_DEPS (ALL_EMPS - EMPS_WITH_DEPS) RESULT LNAME, FNAME (EMPS_WITHOUT_DEPS * EMPLOYEE)