Section 7 Quiz [PDF]

  • 0 0 0
  • Suka dengan makalah ini dan mengunduhnya? Anda bisa menerbitkan file PDF Anda sendiri secara online secara gratis dalam beberapa menit saja! Sign Up
File loading please wait...
Citation preview

Section 7 Quiz (Answer all questions in this section) 1.You need to join the EMPLOYEES table and the SCHEDULES table, but the two tables do not have any corresponding columns. Which type of join will you create?



Mark for Review (1) Points



A full outer join An equijoin A non-equijoin (*) It is not possible to join these two tables. Correct 2.Which statement about joining tables with a non-equijoin is false?



Mark for Review (1) Points



A WHERE clause must specify a column in one table that is compared to a column in the second table (*) The number of join conditions required is always one less than the number of tables being joined The columns being joined must have compatible data types None of the above Correct 3.Nonequijoins are normally used with which of the following? (Choose two)



Mark for Review (1) Points



(Choose all correct answers) Ranges of text Ranges of rowids Ranges of dates (*) ranges of columns Ranges of numbers (*) Correct 4.The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of the ORDERS table. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you need to display. Which type of join should you use to display the data?



Mark for Review (1) Points



Self-join Natural join Equijoin Outer join (*) Correct 5.Which statement about outer joins is true?



The FULL, RIGHT, or LEFT keyword must be included. The OR operator cannot be used to link outer join conditions. (*) The tables must be aliased. Outer joins are always evaluated before other types of joins in the query. Correct 6.Evaluate this SELECT statement: SELECT p.player_id, m.last_name, m.first_name, t.team_name FROM player p LEFT OUTER JOIN player m ON (p.manager_id = m.player_id) LEFT OUTER JOIN team t ON (p.team_id = t.team_id); Which join is evaluated first?



Mark for Review (1) Points



Mark for Review (1) Points



The join between the player table and the team table on MANAGER_ID The join between the player table and the team table on PLAYER_ID The self-join of the player table (*) The join between the player table and the team table on TEAM_ID Correct 7. The ID column in the CLIENT table that corresponds to the CLIENT_ID column of the ORDER table contains null values for rows that need to be displayed. Which type of join should you use to display the data?



Mark for Review (1) Points



Outer join (*) Self join Nonequi-Join Equijoin Correct 8. What is the result of a query that selects from two tables but includes no join condition?



Mark for Review (1) Points



A syntax error A selection of matched rows from both tables A Cartesian product (*) A selection of rows from the first table only Correct 9. When must column names be prefixed by table names in join syntax? Only when query speed and database performance is a concern When the more than two tables participate in the join When the same column name appears in more than one table of the query (*) Never Correct



Mark for Review (1) Points



10. You have the following EMPLOYEES table: EMPLOYEE_ID NUMBER(5) NOT NULL PRIMARY KEY FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) ADDRESS VARCHAR2(35) CITY VARCHAR2(25) STATE VARCHAR2(2) ZIP NUMBER(9) TELEPHONE NUMBER(10) DEPARTMENT_ID NUMBER(5) NOT NULL FOREIGN KEY The BONUS table includes the following columns: BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY ANNUAL_SALARY NUMBER(10) BONUS_PCT NUMBER(3, 2) EMPLOYEE_ID VARCHAR2(5) NOT NULL FOREIGN KEY You want to determine the amount of each employee's bonus as a calculation of salary times bonus. Which of the following queries should you issue? SELECT e.first_name, e.last_name, b.annual_salary, b. bonus_pct FROM employees e, bonus b WHERE e.employee_id = b.employee_id; SELECT e.first_name, e.last_name, b.annual_salary, b. bonus_pct FROM employees, bonus WHERE e.employee_id = b.employee_id; SELECT e.first_name, e.last_name, b.annual_salary * b. bonus_pct FROM employees e, bonus b WHERE e.employee_id = b.employee_id; (*) SELECT first_name, last_name, annual_salary * bonus_pct FROM employees, bonus NATURAL JOIN; Correct



Mark for Review (1) Points



11.Evaluate this SQL statement:



Mark for Review (1) Points



SELECT e.employee_id, e.last_name, e.first_name, d.department_name FROM employees e, departments d WHERE e.department_id = d.department_id AND employees.department_id > 5000 ORDER BY 4; Which clause contains a syntax error? AND employees.department_id > 5000 (*) FROM employees e, departments d WHERE e.department_id = d.department_id ORDER BY 4; SELECT e.employee_id, e.last_name, e.first_name, d.department_name Correct 12. You have two tables named EMPLOYEES and SALES. You want to identify the sales representatives who have generated at least $100,000 in revenue. Which query should you issue? SELECT e.first_name, e.last_name, s.sales FROM employees e, sales s WHERE e.employee_id = s.employee_id AND revenue >= 100000; (*) SELECT first_name, last_name, sales FROM employees e, sales s WHERE e.employee_id = s.employee_id AND revenue > 100000; SELECT e.first_name, e.last_name, s.sales FROM employees, sales



Mark for Review (1) Points



WHERE e.employee_id = s.employee_id AND revenue >= 100000; SELECT e.first_name, e.last_name, s.sales FROM employees e, sales s WHERE e.employee_id = s.employee_id AND revenue > 100000; Correct 13. You have been asked to create a report that lists all corporate customers and all orders that they have placed. The customers should be listed alphabetically beginning with the letter 'A', and their corresponding order totals should be sorted from the highest amount to the lowest amount. Which of the following statements should you issue? SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount FROM customers c, orders o WHERE c.custid = o.custid ORDER BY companyname, amount DESC; (*) SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount FROM customers c, orders o WHERE c.custid = o.custid ORDER BY amount DESC, companyname; SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount FROM customers c, orders o WHERE c.custid = o.custid ORDER BY companyname ASC, amount ASC; SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount FROM customers c, orders o WHERE c.custid = o.custid ORDER BY companyname, amount; Correct



Mark for Review (1) Points



14. If table A has 10 rows and table B has 5 rows, how many rows will be returned if you perform a equi-join on those two tables?



Mark for Review (1) Points



50 It depends on how many rows have matching data in each of the two tables. (*) 5 10 Correct 15. Oracle proprietary JOINS can use the WHERE clause for conditions other than the join-condition. True or False? True (*) False Correct



Mark for Review (1) Points