10 likes | 389 Views
Example. Schema : Employee (ENO, ENAME, TITLE) Works_On (ENO, PNO, RESP, DUR) Project (PNO, PNAME) Query : “Find the names of employees other than J. John who worked on the CAD/CAM project for either one or two years”. The SQL expression : SELECT ENAME
E N D
Example Schema: Employee (ENO, ENAME, TITLE) Works_On (ENO, PNO, RESP, DUR) Project (PNO, PNAME) Query: “Find the names of employees other than J. John who worked on the CAD/CAM project for either one or two years”. The SQL expression: SELECT ENAME FROM Project, Employee, Works_On WHERE Works_On.ENO = Employee.ENO AND Works_On.PNO = Project.PNO AND Employee.ENAME ‘J. John’ AND Project.PNAME = ‘CAD/CAM’ AND (Project.DUR = 12 OR Project.DUR = 24) Project Select PNO Join ENO Project Works-On Employee Figure 1: Operator Tree PNO ENO Project Works-On Employee Employee Project Works-On Figure 2: Another Operator Tree Figure 3: Operator Tree after applying the restrictions