database design - section 18 - oracle...

54
Database Design - Section 18 Instructor Guide

Upload: buinguyet

Post on 28-Apr-2018

227 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Database Design - Section 18 Instructor Guide

Page 2: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design
Page 3: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page i

Table of Contents

Database Design - Section 18 ..........................................................................................................................1 Lesson 1 - Logical Comparisons and Precedence Rules................................................................................1 What Will I Learn? ........................................................................................................................................2 Why Learn It?................................................................................................................................................3 Tell Me / Show Me........................................................................................................................................4 Try It / Solve It ..............................................................................................................................................11 Lesson 2 - Sorting Rows................................................................................................................................16 Why Learn It?................................................................................................................................................18 Tell Me / Show Me........................................................................................................................................19 Try It / Solve It ..............................................................................................................................................24 Lesson 3 - Practice Exercises and Quiz .........................................................................................................26 What Will I Learn? ........................................................................................................................................27 Why Learn It?................................................................................................................................................28 Tell Me / Show Me........................................................................................................................................29 Try It / Solve It ..............................................................................................................................................30 Lesson 4 - Mock Interview............................................................................................................................35 What Will I Learn? ........................................................................................................................................37 Why Learn It?................................................................................................................................................38 Tell Me / Show Me........................................................................................................................................39 Try It / Solve It ..............................................................................................................................................40 Lesson 5 - Introduction to Functions – Single-Row Functions......................................................................41 What Will I Learn? ........................................................................................................................................42 Why Learn It?................................................................................................................................................43 Tell Me / Show Me........................................................................................................................................45 Try It / Solve It ..............................................................................................................................................49

Page 4: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design
Page 5: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 1

Lesson 1 - Logical Comparisons and Precedence Rules

Lesson 1 - Logical Comparisons and Precedence Rules

Lesson Preparation

Evaluate logical comparisons to restrict the rows returned based on two or more conditions. Apply the rules of precedence to determine the order in which expressions are evaluated and calculated.

What to Watch For Students will need practice understanding and using the AND condition. When using AND, both conditions must be true. If one or both conditions aren't true, the statement is false and then only the OR condition is used, if present.

Connections Reinforce the OR condition with an example from data modeling. In the DJs on Demand data model, the entity EVENT had a relationship with two other entities, PRIVATE HOME and PUBLIC PLACE. In the ERD, an arc was drawn across the two relationship lines to signify the OR condition. An EVENT had to be held in either a PRIVATE HOME or a PUBLIC PLACE. Another example of the OR condition can be shown in data modeling when modeling subtypes. The Global Fast Foods staff were either order takers, cooks, managers, or other. A staff member could not be both an order taker and a cook. In this example, these four job titles were exhaustive and mutually exclusive. Staff were one OR the other.

Page 6: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 2

What Will I Learn?

What Will I Learn?

Page 7: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 3

Why Learn It?

Why Learn It?

Page 8: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 4

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Begin the class with a review question. Write a select statement to find an address in the DJs on Demand database d_venues table that has the word "Primrose" in the description. Answer: SELECT address FROM d_venues WHERE address LIKE '%Primrose%' …WHERE cd_id NOT IN(105, 206, 332); …WHERE cd_id != 105 and cd_id != 206 and cd_id!= 332; Will a query using this WHERE clause select cd_id = 206? No Students should not have difficulty with this lesson. It will be necessary to reinforce the AND condition when used with OR. Reinforce the order of precedence in that AND will be evaluated first. However, if one of the AND conditions is false, the whole condition is false. In that case, the OR operator is used to restrict the rows.

Page 9: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 5

Page 10: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 6

Tell Me / Show Me

Tell Me / Show Me

Page 11: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 7

Tell Me / Show Me

Tell Me / Show Me

Page 12: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 8

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Review each example. Reinforce the AND operator when it is true and when it is false. Use the following examples. Ask students to give an example that would be false in each situation. 1. employee_id = 100 AND last_name LIKE 'S%' Ms. Smith whose employee_id is 50 Employee_id 100 whose last name is King 2. Wash the car and fill it up with gas I only washed the car I filled up the car but didn't wash it yet 3. Eat breakfast and watch tv She ate breakfast and went to school She went to school but forgot to eat breakfast 4. department = 10 AND employee_id = 100; Employee_id 100 is in department 20 Employee_id 50 is in department 10

Page 13: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 9

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

These rules are very important. Ask students to view the data in the d_partners table or do a SELECT * from table. Ask students to look at the two examples shown. Without actually querying the table, what output is expected? Accept all answers. Ask students to do a query using each example. Is the output what they expected? Review the output with the students. SELECT last_name, specialty, auth_expense_amt FROM d_partners WHERE specialty ='All Types' OR specialty IS NULL AND auth_expense_amt = 300000; The order of operations is: 1. Specialty IS NULL AND auth_expense_amt = 300000. Both these conditions must be met to be returned. 2. Any instance of specialty = 'All Types' will be returned. SELECT last_name, specialty, auth_expense_amt FROM d_partners

Page 14: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 10

WHERE (specialty ='All Types' OR specialty IS NULL) AND auth_expense_amt = 300000; The order of operations is: 1. The values in the parentheses are selected. 2. All instances of the values in the parentheses that also match auth_expense_amt = 300000 will be returned.

Page 15: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 11

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers 1. The AND condition must satisfy both code and description to return a value. The OR condition will return values that satisfy either condition. 2. SELECT last_name FROM f_staffs WHERE last_name LIKE '%e%' AND last_name LIKE '%i%'; 3. SELECT last_name FROM f_staffs WHERE salary > 6.50 AND staff_type!= 'Order Taker'; 4. SELECT last_name FROM employees WHERE last_name LIKE 'D%a%e%' or last_name LIKE 'D%e%a';

Page 16: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 12

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers 5. SELECT loc_type FROM d_venues WHERE loc_type NOT IN('Private Home'); 6. c. NOT, AND, OR 7. SELECT first_name, last_name FROM employees WHERE last_name LIKE '%en%' and salary < 8000 and hire_date BETWEEN '01-JUN-98' AND '31-MAY-99'; Diana Lorentz 8. SELECT email FROM employees WHERE hire_date BETWEEN '01-JAN-96' AND '31-DEC-96' AND salary > 9000 AND commission_pct IS NULL;

Page 17: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 13

MHARTSTE An alternative solution for #8 is: SELECT email FROM employees WHERE hire_date > '01-JAN-96' AND salary > 9000 AND commission_pct IS NULL;

Page 18: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 14

Try It / Solve It

Try It / Solve It

Try It / Solve It

Reinforce the importance of coding the practice exercises and looking at the data returned. Students will accept the results of a query just because it executed without looking at the result set to verify that the values returned satisfy the conditions in the query. Demonstrate the following example which executes, but does not return, the desired results. The logical operator should be AND, not OR. Omitting the salary columns, the result set doesn't show that the salary condition is not met by the statements in the query. What are the titles of the jobs whose minimum salary is 4000 and whose maximum salary is 9000? SELECT job_title FROM jobs WHERE min_salary = 4000 or max_salary = 9000; Rewritten query including the salary columns to verify that both conditions are met: SELECT job_title,min_salary, max_salary FROM jobs WHERE min_salary = 4000 AND max_salary = 9000;

Page 19: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 15

Page 20: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 16

Lesson 2 - Sorting Rows

Lesson 2 - Sorting Rows

Lesson Preparation

None. What to Watch For

Ordering by single columns should be easy for most students. To help make ordering by more than one column more understandable, use practical examples such as: - The department store manager would like a list of all the shoes sorted by type and then by size for each type. Have students talk in SQL to give their answers (e.g., SELECT name, type, size FROM shoes ORDER BY type, size). - The restaurant manager would like a list of all the spices used by the cooks. The list should be organized first by the spice type (ginger, cinnamon, thyme, etc.) then by spice category (spice, herb, or seasoning). For example, SELECT spice_name, spice_type, spice_category FROM spices ORDER BY spice_type, spice_category.

Connections Relate the ordering of information to the whole process of designing an ERD. Entities in an ERD make up the group of information items that are data requirements for a business. An entity is made up of a group of attributes that are properties of the entity.

Page 21: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 17

Before music was available on compact disks (CDs), most music albums were stored on 8-track tapes or vinyl records. If you bought a music tape and wanted to skip to the third song, you had to fast-forward the tape through the first two songs before what you were looking for could be played. The recordings were locked into an order that, many times, was not very convenient and usually not in the order you wanted to listen to them. Today's technology has changed all that. The order in which songs are recorded on a CD is of little significance. With the push of a button, we can play them in any order desired.

Page 22: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 18

Why Learn It?

Why Learn It?

Why Learn It?

Ask students for other ways in which we order our lives. Suggested answers: Library books in library, grocery-store shelves, department stores, parking lots, and file cabinets.

Page 23: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 19

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

To reinforce the difference between ascending (ASC) and descending (DESC), ask students the following questions: 1. If your last name is Yonkers, are you in the front or back of the line in ASC order? Back of the line 2. If you wanted to sort your address book in DESC order, what names could appear before mine? Answers will vary depending on the instructor's last name. 3. Would the student who would be first in line in ASC order please raise your hand? Answers will vary depending on the class list of names. Discuss and relate instances of ordering and sorting that can be found in school, at home, or in the business world. How do retail stores order their merchandise? How do websites with directories like Yahoo decide how to organize and order the information on their home page?

Page 24: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 20

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Dates can be confusing. The earliest dates are displayed first. Use the dates below to demonstrate that a date in 1985 would be at the top of a list of dates ordered in ascending order. Null values in ASC order are displayed last. Place the following dates in descending order: 22-MAY-85, null, 10-JAN-04, 17-NOV-55, 21-DEC-98 Answer: null, 10-JAN-04, 21-DEC-98, 22-MAY-85, 17-NOV-55 The following query can be used to demonstrate this concept: SELECT hire_date FROM employees ORDER BY hire_date DESC;

Page 25: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 21

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Explain the query execution order. Ask students to have a mental picture of being able to walk into a database to find information just like finding a book in a library. SELECT employee_id, first_name FROM employees WHERE employee_id < 105 ORDER BY last_name;

Page 26: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 22

Explain to students that it’s difficult to verify your results when you sort by a column that you’re not SELECTing. In the real world, you would run your query selecting the last_name column until you were sure you were getting the right data. Then you could remove that column from your SELECT statement.

Page 27: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 23

Tell Me / Show Me

Tell Me / Show Me

Page 28: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 24

Try It / Solve It

Try It / Solve It

Tell Me / Show Me

Answers: 1. SELECT employee_id AS "Number", first_name, last_name FROM employees ORDER BY "Number"; 2. SELECT title, year FROM d_cds ORDER BY year, title; 3. SELECT title AS "Our Collection" FROM d_songs ORDER BY title DESC;

Page 29: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 25

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 4. SELECT first_name, last_name, student_id, year_in_school, parking_space FROM students WHERE year_in_school = 1 ORDER BY last_name, first_name DESC; (exact syntax names will vary) 5. SELECT department_id, last_name, manager_id FROM employees WHERE employee_id < 125 ORDER BY department_id DESC, last_name DESC; Discuss the graphics with students. Write SELECT statements for each. SELECT DISTINCT item_number, item_names ASC FROM inventory; SELECT last_name, salary DESC; FROM employees; ORDER BY salary DESC;

Page 30: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 26

Lesson 3 - Practice Exercises and Quiz

Lesson 3 - Practice Exercises and Quiz

Lesson Preparation

Review study guide with students. Review vocabulary exercise with students. Review SQL syntax. Ask students which problems they find difficult. Students should take the quiz after completing the practices exercises in this lesson.

What is Watch For Students should achieve 70% or better on the quiz. Provide enough time to review for the quiz. After the quiz, review the most difficult questions. Encourage students to practice their skills using self-test software. After students have completed the quiz in this section, review selected questions from the quiz. It is helpful to take the quiz yourself. Give a brief overview of what's next.

Connections None.

Page 31: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 27

What Will I Learn?

What Will I Learn?

Page 32: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 28

Why Learn It?

Why Learn It?

Page 33: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 29

Tell Me / Show Me

Tell Me / Show Me

Page 34: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 30

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 1. e. Selection 2. c. ORDER BY 3. a. SELECT d. FROM

Page 35: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 31

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 4. a, b, and c are true 5. c. To select last_names without duplicates 6. d. SELECT first_name ||' ' ||last_name ||' is an '||staff_type||' for Global Fast Foods'

Page 36: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 32

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 7. All of the above will return uppercase column headings by default 8. a,b,c will return last names in alphabetical order 9. d. SELECT employee_id AS "New Employees"

Page 37: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 33

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 10. c. Arnie Smithers, administration president, 20000 11. WHERE last_name LIKE 'St%'; 12. COMPENSATION Commission (null) Commission is

Page 38: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 34

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 13. Values less than or equal to 1900 or greater than or equal to 2100 will be included in the result set. 14. a. WHERE department_id NOT IN (101,102,103); b. WHERE last_name = 'King' c. WHERE start_date LIKE '05-MAY-98' d. WHERE salary BETWEEN 5000 AND 7000 e. WHERE id != 10 15. 410 Assist students in completing assignments. Review selected practice questions with students. Allow enough time to complete the quiz.

Page 39: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 35

Lesson 4 - Mock Interview

Lesson 4 - Mock Interview

Lesson Preparation

Doing research and conducting the interview may take longer than one class period. You may want to give students copies of the following articles or direct them to Internet resources to narrow their search. The following sites provide information students could use to formulate questions for the interview: http://www.oracle.com/corporate/index.html?lje_content.html http://www.oracle.com -- Under the heading "Resources" in the left margin, click on "Company Information." CEO_Article_1 Tailoring Databases for Life Science CEO_Article_2 Larry Ellison

What to Watch For Set the tone of this exercise from the beginning. Let students know that the interview should be as close to "real" as they can make it. Review your expectations with students.

Connections Ask a school official or someone who hires employees to speak to the class about what qualities they look for in a candidate when conducting a job interview.

Page 40: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 36

Some students in the class may have been interviewed for a job, a scholarship, or an internship. Have students relate their experiences. Relate your own experiences in getting a teaching job and the interview process for the job. Discuss why interviews are conducted and the types of interviews students might expect seeking a job, entrance into college, a scholarship, or internship. Internet keyword search "types of interviews."

Page 41: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 37

What Will I Learn?

What Will I Learn?

Page 42: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 38

Why Learn It?

Why Learn It?

Page 43: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 39

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

The purpose of the mock interview is to introduce students to the interviewing process. This will allow them to organize and prepare what they want to say as well as how they want to say it. Help students formulate open-ended questions rather than questions that can be answered with a "yes" or "no" (not the best questions for getting an interview subject to share information). For example, "What are the hardest things you have to do as the CEO of such a large company?" "What's a typical business day like for you?" Instead of, “Do you like working for Oracle Corporation?,” ask “Why do you like working for Oracle Corporation?” Your role as "Larry Ellison" will be to respond to questions and keep students focused and on task. This simulation should be fun but business-like. This is a good time for you to start contacting other faculty members and local businesses for guest speakers and/or volunteer interviewers. A great resource to start with is the International Oracle User's Group (IOUG). Search for a local contact in your area: US - link UK - link Europe - link

Page 44: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 40

Try It / Solve It

Try It / Solve It

Try It / Solve It

Prepare a list of questions for an interview with Larry Ellison, CEO of Oracle. This exercise is intended to be lighthearted and fun. Give students the freedom to structure this interview. - Using research on the Oracle website, knowledge of new or existing Oracle products, Oracle's history, or news stories about Larry's personal/business life, ask students to create five leading, open-ended questions. One of the questions may be something personal directed to Larry Ellison, but the others should stay focused on business. - Have at least three students act out their fictitious interviews. A suggested method is the "fishbowl" technique. This requires assigning one student to be Larry Ellison and another to be the candidate. Students who are observers will constructively critique the interviews and make suggestions to improve the interview questions. This is an effective technique for simulating the interview experience and allowing other students to see what works and what doesn't. - Instructors and students should begin searching/contacting other faculty members, school administrators, and/or local businesses for job-shadowing opportunities. A sample letter for instructors to send to local businesses inquiring about job-shadowing opportunities can be obtained here. This can be modified for students to use in making their own inquiries.

Page 45: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 41

Lesson 5 - Introduction to Functions – Single-Row Functions

Lesson 5 - Introduction to Functions –Single-Row Functions

Lesson Preparation

None. What to Watch For

You can't assign too much practice with functions! The next sections present them in depth. Connections

Ask students who have used a library computer system to search for a specific book, if they had to enter the book title/author or subject in uppercase or lowercase? Did it matter what case the query was entered in? Most likely the computer program had built-in functions to handle this situation. Having functions built into programs makes data retrieval seamless for the user.

Page 46: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 42

What Will I Learn?

What Will I Learn?

Page 47: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 43

Why Learn It?

Why Learn It?

Why Learn It?

How could you find out whether the information in the DJ on Demand CD titles table is stored in uppercase or lowercase? Execute a SELECT statement for the column in HTML DB and look at the output. SELECT title FROM d_cds; What if the report you're reading has the date displayed as April 14th, 2004, but you know the data is stored in an internal numeric format and displayed in the DD-MON-YY format? The person who created the report changed the date format in the query. SELECT last_name, TO_CHAR(hire_date, 'Month ddth, YYYY') FROM employees; Explain to students that had they been the person searching for cd at the kiosk, they would have not made that case mistake! Explain the graphic to students. Define arg (arguments) as input values to functions. Functions use one or more arguments to perform calculations and in turn produce output. Input values

Page 48: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 44

will be changed or transformed into something different as output -- that's the purpose of a function. Help students organize the SQL syntax for each of the five groups of single-row functions. Use the single-row functions graphic each time a new group is introduced.

Page 49: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 45

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Begin this lesson with a review question. How would you write a query to sort the song titles in the DJ database alphabetically? SELECT title FROM d_songs This lesson begins with an introduction to SQL functions and concludes with the History of Computing activity. Learning the many different functions can be a challenge for students. Focus on helping students see the big picture of the different categories of functions and the syntax for each type. If possible, copy for students the list of functions (link to it). It will help them organize the information in this and subsequent sections about functions. Students could make posters that summarize the different groups of functions. It may also help them organize the information. Display the Single-Row Functions graphic each time you teach a new function group. Read and discuss what functions are capable of accomplishing. Give examples for each and ask "What advantages do these capabilities offer businesses?" Look for answers that Include:

Page 50: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 46

- Readability (you can store the date with date, hours, minutes, and seconds, but the user may only care about day, month, and year); - Formatting (numbers in the data base, such as salary data, lack formatting. The user, however, may require numeric data displayed as $ for United States dollars or £ for British pounds); - Ease of use in data entry (dates entered as Month dd, RRRR are converted to the default format using date conversions).

Page 51: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 47

Tell Me / Show Me

Tell Me / Show Me

Page 52: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 48

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Demonstrate the following examples of single-row functions to give students a preview for what's ahead. Explain that SQL functions are statements used to perform program-specific tasks. Ask students to identify the function in each example. SELECT 'The most popular song in our collection is ' || UPPER(title)AS "Most Requested" FROM d_songs WHERE id = 47

SELECT CONCAT(title, year) FROM d_cds;

Page 53: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 49

Try It / Solve It

Try It / Solve It

Try It / Solve It

In this lesson, students will use the Internet to research the people and businesses that contributed to the development of the Internet. Internet search keywords "internet timeline" or "Hobbe's Internet Timeline." Using adding-machine-tape paper or poster paper cut into strips, create a 10-foot mural for the classroom. Divide the paper into a timeline as follows: allow about 1/4 of the length from 1800 to 1970 and the remaining 3/4 from 1970 to present. Assign topics to groups. Each group should find a minimum of four events. Each group must identify a person, a place, and a thing associated with their topic. The topics to be included are: - Historical thinkers: people without whose inventions computers and communication as we know it today could not be possible (Samuel Morse, Alexander Graham Bell, Vannevar Bush) - Enablers: universities, government agencies, and businesses that contributed to the idea of the Internet and birth of the Internet (ARPANET, NSF, CERN, Rand Corp.) - Communicators: people who developed computer languages, computer networks, and the technology to be able to talk computer to computer (Ray Tomlinson, Bob Metcalf, Vinton Cerf, Larry Wall)

Page 54: Database Design - Section 18 - Oracle Academyacademy.oracle.com/.../Database_Design_-_Section_18_Instructor_G… · Copyright © Oracle, 2004. All rights reserved. Database Design

Copyright © Oracle, 2004. All rights reserved.

Database Design - Section 18 Page 50

- Innovators: people and business that enabled the average person to be able to use a computer and communicate on the Internet (Microsoft, Apple, AOL, Netscape, Yahoo) - Movers and shakers: people and companies that transformed the Internet into a virtual mall of information and services (Oracle, Amazon.com, EBay, MSN)