SJLSHS - Computer Programming - Oracle Database
SJLSHS - Computer Programming - Oracle Database
Programming
(Oracle Database)
QUARTER 1
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 1
MODULE 1 PART 1 INTRODUCTION TO DATA
Performance Standard:
The learners shall be able to independently create/provide quality and marketable
product and / or service in Computer Programming, as prescribed by TESDA Training Regula-
tions
Objectives:
1. Discuss and Differentiate between Data and Information
2. Discuss and Explain the Number System and its Conversion in Programming
3. Explain the use of ASCII Code.
4 Discuss and Explain the term Bytes and its Conversion.
I What is new?
Computer programming is a way of giving computers instructions about what they
should do next. These instructions are known as code, and computer programmers write code
to solve problems or perform a task. [1] In computer programming, you will deal with data and
how data is important in doing an application. In this lesson, you will understand the term
“data” in different aspect in computer programming.
Data is raw, unorganized facts that need to be processed. Data can be something
simple and seemingly random and useless until it is organized. When data is processed,
organized, structured or presented in a given context so as to make it useful, it is called
information.[2]
ACTIVITY #1: DATA vs INFORMATION
Based on the example below, determine whether the statement is a Data or
Information. Write your answer in the space provided.
1. Soy Sauce, Chicken, Vinegar, Pepper, Basil Leaves, Salt ______________
Chicken Adobo ______________
2. The average score of a class _____________
Each student's test score ______________
3. Temperature readings ______________
Global temperature is rising _____________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 2
D What do I know?
D What is in?
ACTIVITY #3: TRUE OR FALSE
Read each statement carefully. Identify whether the statement is TRUE or FALSE.
Write your answer in the space provided after each statement.
1. In binary, the meaning of 0 is ON and 1 is OFF.
2. In ASCII code, the meaning of S is System.
3. The available unit for storage nowadays is terabyte.
4. USB is the secondary storage that used to store different kinds of data.
5. Byte is consist of 8 bits.
D What is it?
ACTIVITY #4: READING ACTIVITY
Read and understand the ideas and concept being presented.
NUMBER SYSTEM
The technique to represent and work with numbers is called number system. Decimal
number system is the most common number system. Other popular number systems include
binary number system, octal number system, hexadecimal number system, etc. [3]
Decimal Number System (Base 10)
Decimal number system is a base 10 number system having 10 digits from 0 to 9. This
means that any numerical quantity can be represented using these 10 digits. Decimal number
system is also a positional value system. This means that the value of digits will depend on its
position. Also, this is the number system we used in everyday life like our money, time, etc.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 3
Let us take an example to understand this.
Say we have three numbers: 923, 790 and 519. The value of 9 in all three numbers is different
because of its location.
In 923, value of 9 is 9 hundreds or 900 or 9 × 100 or 9 × 10 2
In 790, value of 9 is 9 tens or 90 or 9 × 10 or 9 × 10 1
In 519, value of 9 is 9 units or 9 or 9 × 1 or 9 × 10 0
The weightage of each position can be represented as follows:
In digital systems, instructions are given through electric signals; variation is done by varying
the voltage of the signal. Having 10 different voltages to implement decimal number system in
digital equipment is difficult. So, many number systems that are easier to implement digitally
have been developed. [3]
In any binary number, the rightmost digit is called least significant bit (LSB) and left-
most digit is called most significant bit (MSB).
The main advantage of using binary is that it is a base which is easily represented by
electronic devices. The Binary Number System are also ease of use in coding, fewer computa-
tions and less computational errors. [3]
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 4
CONVERSION OF ONE NUMBER SYSTEM TO ANOTHER NUMBER SYSTEM
Question: Why do we need various number base conversions?
Answer: We communicate with each other in a particular language made of letters or
words. We normally type letters or words through keyboard of the computer, but computer
does not understand the words and letters. Rather, those words and letters are translated into
numbers. This means that computers understand only numbers. We know the decimal (base
10) system, and are very comfortable with performing operations using this system, it is also
important for us to understand that the decimal system is not the only system in the world.
By studying other number systems such a s binary (base 2), quaternary (base 4), octal
(base 8), hexadecimal (base 16) and so forth, we will gain a better understanding of how num-
ber systems work in general. Number systems are the technique to represent numbers in the
computer system architecture, every value that you are saving or getting into/from computer
memory has a defined number system. As Computer architecture supports following number
systems so we need to study them and also need to know the conversion technique between
them. [4]
Conversion of Decimal (Base 10) to Another Base (Binary [2], Octal [8], Hexadecimal [16])
Example: 18510 = _________2 = _________8 = _________16
Step 2: Get the quotient (whole number do not round off) and the remainder.
Solution: 185 / 2 = 92 r. 1 185 / 8 = 23 r. 1 185 / 16 = 11 r. 9
Note: r. means remainder, the 2, 8, 16 are the converting base.
Step 3: Use the quotient and divide again to converting base as long as the quotient
reaches to 0.
Step 4: Get all the remainder and align it as one number from bottom to top.
Solution: 92 / 2 = 46 r. 0 23 / 8 = 2 r. 7 11 / 16 = 0 r. 11/B
46 / 2 = 23 r. 0 2 / 8 = 0 r. 2
23 / 2 = 11 r. 1
11 / 2 = 5 r. 1
5 / 2 = 2 r. 1
2 / 2 = 1 r. 0
1 / 2 = 0 r. 1
ANSWER: 101110012 2718 B916
So, the equivalent of 18510 in binary is 101110012, in octal is 2718 and in hexadecimal is B916.
Note: In hexadecimal, we must convert the numbers exceeded to 9 into its equivalent letters
because each digit has different value.
Conversion of Binary (2), Octal (8) or Hexadecimal (16) into Decimal (10)
Example: 10112 = ______ , 3268 = ______, A416 = ______
STEP #1: Write the numbers from top to bottom based on its value from right to left.
Solution: 1 6 4
1 2 A (10)
0 3
1
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 5
STEP #2: Multiply the value of each number based on its origin based raised to its position
starting to 0.
STEP #3: Add all the product and that is the answer.
Solution: 1 x 20 = 1 x 1 = 1 6 x 80 = 6 x 1 = 6 4 x 160 = 4 x 1 = 4
1 x 21 = 1 x 2 = 2 2 x 81 = 2 x 8 = 16 A(10) x 161 = 10 x 16 = 160
0 x 22 = 0 x 4 = 0 3 x 82 = 3 x 64 = 192 Sum: 164
1 x 23 = 1 x 8 = 8 Sum: 214
Sum: 11
So, 10112 = 1110 , 3268 = 21410 , A416 = 16410
STEP#2: Use the number 421 (for Octal) or 8421 (for Hexadecimal) and put it on the top of
separated values / group.
Solution:
421 421 8421 8421
101 110 0010 1110
STEP#3: Add all the numbers with 1 below the number (421 or 8421). Then, put together the
numbers and that is the answer.
Solution:
421 421 8421 8421
101 110 0010 1110
4+1 4+2 2 8+4+2
5 6 2 14 €
Note: Always convert the hexadecimal numbers into its equivalent letters (10-15).
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 6
Conversion of Octal (8) or Hexadecimal (16) into Binary (2)
Example 4038 = _______2 F7A16 = ________2
STEP#1: Separate each octal / hexadecimal value from each other.
Solution:
4 0 3 F(15) 7 A(10)
STEP#2: Use 421 (for Octal) and 8421 (for Hexadecimal) on each number. Then, what are
numbers that need to add to get the number. Put 1 if it is used and 0 if it is not. Put it
together and that is the answer.
Solution:
4 0 3 15 7 10
421 421 421 8421 8421 8421
100 000 011 1111 0111 1010
Answer:
4038 = 1000000112 F7A16 = 1111011110102
——————————————————————————————————————————————
ASCII Code
Besides numerical data, computer must be able to handle alphabets, punctuation marks,
mathematical operators, special symbols, etc. that form the complete character set of English
language. The complete set of characters or symbols are called alphanumeric codes. The
complete alphanumeric code typically includes −26 upper case letters, 26 lower case letters,
10 digits, 7 punctuation marks and 20 to 40 special characters
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 7
Here is the equivalent ASCII Code for each character:
The ASCII Code for each letter is in decimal number system. Character means any let-
ter, number, space or special character. When you type something in the keyboard, the com-
puter does not understand what you are typing. It has a program wherein the character is
converted to its equivalent ASCII code and convert it again into binary numbers because only
1’s and 0’s can be understand by the computer.
Example: When we type the text: Cut 3 in the keyboard to the computer. It will con-
vert the text (Cut 3) into ASCII code: 68 117 116 32 51. After that we must convert each
ASCII Code in decimal number into binary numbers. So, the following the steps on conversion
of decimal to number, here is the solution:
Solution:
68/2 = 34 r. 0 117/2 = 58 r. 1 116/2 = 58 r. 0 32/2 = 16 r. 0 51/2 = 25 r. 1
34/2 = 17 r. 0 58/2 = 29 r. 0 58/2 = 29 r. 0 16/2 = 8 r. 0 25/2 = 12 r. 1
17/2 = 8 r. 1 29/2 = 14 r. 1 29/2 = 14 r. 1 8/2 = 4 r. 0 12/2 = 6 r. 0
8/2 = 4 r. 0 14/2 = 7 r. 0 14/2 = 7 r. 0 4/2 = 2 r. 0 6/2 = 3 r. 0
4/2 = 2 r. 0 7/2 = 3 r. 1 7/2 = 3 r. 1 2/2 = 1 r. 0 3/2 = 1 r. 1
2/2 = 1 r. 0 3/2 = 1 r. 1 3/2 = 1 r. 1 1/2 = 0 r. 1 1/2 = 0 r. 1
1/2 = 0 r. 1 1/2 = 0 r. 1 1/2 = 1 r. 1
1000100 1110101 1110100 10000 110011
Note: The number must be in 8 bits or 8 binary numbers, so if the answer for each binary
number does not reach into 8 bits, we must add 0’s before the number to make it 8 bits.
01000100 01110101 01110100 00010000 00110011
Answer:
When you type the text: Cut 3, the computer understand it as
01000100 01110101 01110100 00010000 00110011
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 8
ACTIVITY #6: ASCII Code
DIRECTIONL: Convert the following values into ASCII code and binary numbers. Write your
answer on the blank provided below.
1. ________________________________________________________________________________________
2. ________________________________________________________________________________________
3. ________________________________________________________________________________________
——————————————————————————————————————————————
BYTES
A byte is a unit of data that is 8 bits long. A byte is the standard “chunk size” for binary in-
formation in most modern computers. You may have heard "megabyte", "kilobyte", "gigabyte",
etc. which are all different amounts of a bytes. A data with 4 bits size is called Nimble. Bit is
the smallest unit of data.[5]
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 9
E What is more?
ACTIVITY#8: SUMMATIVE ASSESSMENT:
A. Number System and its Conversion
Direction: Complete the table below. You can use any kind of conversion techniques on ob-
taining the correct answer. Show your solution in the different paper. (2pts each per number)
B. ASCII Code
Direction: Decode the following computer language into text and show your calculation steps
on how you get the hidden text. (5 points per number) .
C. Bytes
Direction: Solve the given statement. Show your computation.
1. John has a 1 GB floppy disk. How many 513 kilobytes file will be stored?
2. Alice wants to store fifty 100 mb files in her 2GB flash disks. How many flash disks she
needs?
3. Anna needs a flash disk that will store his one 1.2 GB movie file, five 500 mb image files
and two 3.7 GB installer files. How many flash disks she needs?
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 10
E What can I do?
ACTIVITY#9: What other enrichment activities can I engage in? (Additional Activities)
Direction:
1. Go to the notepad, type “Hello” and save it.
2. Go to the Microsoft word, type “Hello” and save it.
3. Click to the created file (text file and docx file) and go to its Properties. Get the size of each
file.
Questions: Answer the questions based on the procedure above.
1. What is the file size of text file? _______________________
2. How about the docx file? _______________________
3. Why the 2 files have a different file size? What are the factors?
___________________________________________________________________________________________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 11
A What I can achieve?
ACTIVITY #11: APPLICATION
Direction: Search in the internet the following information:
I. In what areas we can use the following number system?
1.Decimal: ______________________ 3. Octal: _____________________________
2. Binary: _______________________ 4. Hexadecimal: ______________________
II. In following size of data, what kind primary or secondary storage has this capacity?
Example: Kilobyte ____Floppy Disk
5. Megabyte ______________________
6. Gigabyte _______________________ 7. Terrabyte ______________________
Reflection
Direction: Write your personal insights about the lesson using the prompt below.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 12
MODULE 1 PART 2 INTRODUCTION TO DATABASE
Performance Standard:
The learners independently apply the fundamentals of SQL using Oracle Database
technology. Specifically, it teaches the concepts of relational databases and the SQL program-
ming language. It teaches how to write queries against single and multiple tables, manipulate
data in tables, and create database objects. It also teaches how to use single row functions to
customize output, use conversion functions and conditional expressions based on TESDA
Training Regulations.
Objectives:
1. Define Database. Identify the different terminologies in SQL / Database.
I What is new?
DATABASE
Database, also called electronic database, any collection of data, or information, that is spe-
cially organized for rapid search and retrieval by a computer. Databases are structured to fa-
cilitate the storage, retrieval, modification, and deletion of data in conjunction with various
data-processing operations. A database management system (DBMS) extracts information
from the database in response to queries.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 13
D What do I know?
ACTIVITY #2: PRE-ASSESSMENT
Read and analyze each description carefully. Identify each word and write your answer
into the space provided after each statement.
1. It is a standard language for accessing and manipulating databases.
2. SQL stands for.
3. It is a set commands which are used to retrieve data from database server.
4. It is used to retrieve and manipulate data in a relational database.
5. It is used to build and modify the structure of your tables and other objects in the
database.
D What is in?
D What is it?
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 14
Introduction of SQL
SQL stands for Structured / Standard / Simple Query Language.
It is a programming language which stores, manipulates and retrieves the stored data in
DBMS (DataBase Management System)
SQL syntax is not case sensitive.
SQL is standardized by both ANSI and ISO.
It is a standard language for accessing and manipulating databases .
Data Type
SQL Data Types define the type of value that can be stored in a table column. For example, if
you want a column to store only integer values, then we can define it’s data type as int.
These commands can be used to add, remove or modify tables within a database.
Note: For this lesson we will only discuss about CREATE command.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 15
Based on the table given on the Activity #3, the code for creating that table is.
Example:
CREATE TABLE STUDENTS
(
LRN int,
NAME varchar(30),
BIRTHDAY date,
ADDRESS varchar(50)
);
EXPLANATION:
STUDENTS - The name of the table is STUDENTS because all information is regarding
about the student.
LRN, NAME, BIRTHDAY and ADDRESS - is the column name indicated in the table.
We use int in LRN because you all know that the LRN is a number and it does not con-
tain decimal value.
We use date on BIRTHDATE.
We use varchar on ADDRESS and NAME because it is consists of letters, spaces, spe-
cial characters and numbers.
The 30 and 50 inside the parenthesis of varchar is the length or max number of charac-
ters in NAME and ADDRESS respectively.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 16
Based on the table given on the Activity #3, the code for inserting 1 row of data in the table:
Example:
INSERT INTO STUDENTS VALUES (123, “John Santos”, “01/31/2000”, “Montalban”);
ACTIVTY #5:
Direction: Based on Activity #3, list the remaining code for inserting the 2 rows of data in the
table.
1. _________________________________________________________________________________________
2. _________________________________________________________________________________________
Example #1:
Code: SELECT LRN, NAME, BIRTHDATE, ADDRESS FROM STUDENTS;
Output:
Note: If you want to show or include all the columns, you don’t need to specify all the column
names but you may use the wildcard character (*) in you want to get the in every column in
the table.
Example #2:
Code: SELECT * FROM STUDENTS;
Output:
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 17
Example #3:
Code: SELECT LRN, NAME FROM STUDENT;
Output:
E What is more?
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 18
E What can I do?
ACTIVITY #8: HERO TABLE
Direction: Display the output table of the previous activity.
1. Show all the information on table.
2 Show only the name of each hero.
3. Show only the role, name and price of each hero.
Reflection
Direction: Write your personal insights about the lesson using the prompt below.
I understand that ______________________________________________________
I realized that _________________________________________________________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 19
MODULE 2: NULL, LITERAL, DISTINCT, OPERATOR
Performance Standard:
The learners independently apply the fundamentals of SQL using Oracle Database
technology. Specifically, it teaches the concepts of relational databases and the SQL program-
ming language. It teaches how to write queries against single and multiple tables, manipulate
data in tables, and create database objects. It also teaches how to use single row functions to
customize output, use conversion functions and conditional expressions based on TESDA
Training Regulations.
Objectives:
1. The learners will able to use arithmetic expressions and NULL values
2. The learners will able to describe the concatenation operator, literal character
strings, alternative quote operator, and the DISTINCT keyword
3. The learners will able to implement column aliases
I What is new?
ACTIVITY #1: TOILET PAPER
Direction: Analyze the 3 images about the toilet paper below and explain the differences be-
tween the 3 images.
______________________________________
______________________________________
______________________________________
______________________________________
______________________________________
______________________________________
______________________________________
______________________________________
______________________________________
______________________________________
______________________________________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 20
D What do I know?
ACTIVITY #2: JUMBLED LETTERS
Direction: Unscramble the letters to form the terms associated with different terminologies
that you will encounter in this module. Write your answer in the space provided.
1. SLIAA _______________________________
2. OENATNCATCE _______________________________
3. PAERTORO _______________________________
4. LUNL _______________________________
5. TDCINTIS _______________________________
D What is in?
ACTIVITY #3: BASIC OPERATOR
Direction: Evaluate the following expression and show your calculation steps. Box your final
answer.
1. 8 + 3 * 4 / 2 2. 24 / 3 * 4 3. 5 + (4 - 3) * 6
D What is it?
ACTIVITY #4: READING ACTIVITY
Read and understand the ideas and concept being presented.
Operators
An operator is a reserved word or a character used primarily in an SQL statement's WHERE
clause to perform operation/s, such as comparisons and arithmetic operations.
Arithmetic Operators ( +, -, *, /, %)
Arithmetic Operator
Assume that the variable X holds 7 and variable Y holds 3.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 21
The order of operations as follows:
1. Any operations enclosed in the parentheses are performed first.
2. Then, any multiplication, modulo and division operations are performed next from left to
right.
3. Then, any multiplication, modulo and division operations are performed next from left to
right.
4. Then, any addition and subtraction operations are performed last from left to right.
Example: 30 / (4 + 2) * 3 - 10 % 4 + 5
Explanation:
1. 4 plus 2 is equal to 6.
2. Followed by 30 divided by 6 that result to 5. Then get the remainder of 10 % 4, the result
is 2.
3. Followed by, multiplying the 5 to 3 that results to 15.
4. 2 is subtracted from 15 that yields to 13.
5. Last is 13 will be added by 5. The final result is 18.
Calculation Steps
30 / (4 + 2) * 3 - 10 % 4 + 5
30 / 6 * 3 - 10 % 4 + 5
5*3-2+5
15 - 2 + 5
13 + 5
18
Application of Arithmetic Operator (Basic)
Study the EMPLOYEE table below:
Instruction: List lastname, their department, their salary and the tax of each employee. The
tax is the 20% of the salary.
Code: SELECT LASTNAME, DEPARTMENT, SALARY, SALARY * .20 FROM EMPLOYEE;
Output Table:
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 22
NULL VALUES
Based on the activity #1, you can see 3 different images of toilet paper: the first image shows
that there is plenty paper on the roll, the second image shows that there is no paper on the
roll and the third one, there is no roll for the toilet paper: it means that there is no value.
NULL VS ZERO
NULL - something that there is no value or not specified data available.
ZERO - is a number and it is a value.
For example, there are 2 students that has exam on their Science Subject. One
of the student took the test but his score is 0 and the other student didn’t take the exam be-
cause he has fever. The example of NULL is the student who did not take the exam.
Question: Based on the employee table, who got a null value? Answer: ____________________
DISTINCT KEYWORD
If you look back at the employee table, you’ll notice that something interesting in the
DEPARTMENT column. Many of the employee have the same department. Sometimes, you
might have a situation where you want to see only the unique values for a column that you
know contains many repeated values. There is a keyword called DISTINCT that use to obtain
the unique values for a column containing duplicate.
Example Code: SELECT DISTINCT DEPARMENT FROM EMPLOYEE;
OUTPUT TABLE ->
Note: As you can see in the output table, there is duplicate values in the
DEPARTMENT field.
CONCATENATION
The meaning of Concatenation in SQL is adding several strings together. When you
concatenate columns, you must use the plus sign (+0) A string is a data type used
in programming, such as an integer and floating point unit, but is used to represent text
rather than numbers. If the string is literal (value), you must enclosed the text with
double quotation (“).
Example of Concatenation
Using the EMPLOYEE table on the previous page.
Example #1:
Code: SELECT FIRSTNAME + LASTNAME FROM EMPLOYEE;
OUTPUT TABLE ->
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 23
Note: As you can see, the column name is FIRSTNAME + LASTNAME because that is text we
used in the SELECT clause. As the result for each record / row, the value of firstname and
last name is put together without any spaces. If you want to add space, you must use the
string literal.
Example #2:
Code: SELECT FIRSTNAME + “ ” + LASTNAME FROM EMPLOYEE;
Example #3:
Code: SELECT FIRSTNAME + “-” + LASTNAME FROM EMPLOYEE;
ALIASING
When you code in the SELECT command it copies the column name exactly as you defined it
in the select statement including its formula. Now, there is a keyword for changing the name
of column name called Aliasing. You will used the AS keyword followed by the string literal of
your preferred column name.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 24
E What is more?
Direction: Based on the table in the activity #7. Write the SQL command of the following re-
quirements. Write your answer in the space provided
___________________________________________________________________________________________
___________________________________________________________________________________________
3. Show the champ id, hero name and released date. Change the hero name to heroes.
___________________________________________________________________________________________
4. Show the champ id, hero name, role 2, price and the increased price. The increased price is
10% of the original price.
___________________________________________________________________________________________
__________________________________________________________________________________________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 25
A What I have learned?
ACTIVITY #9: WRITING SQL COMMAND
Direction: Based on the output tables, write the SQL command to obtain the result.
1._________________________________________________________________________________________
__________________________________________________________________________________________
2._________________________________________________________________________________________
__________________________________________________________________________________________
3._________________________________________________________________________________________
__________________________________________________________________________________________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 26
A What can I achieve?
ACTIVITY #10: DRAW THE NULL
Direction: Draw an example of images that describe null values, 0 values and with value just
like in Activity #1. You will be graded by the given rubrics below.
WITH VALUES ZERO VALUE NULL VALUE
Reflection
Direction: Write your personal insights about the lesson using the prompt below.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 27
MODULE 3 SORTING AND RESTRICTING DATA
Performance Standard:
The learners independently apply the fundamentals of SQL using Oracle Database
technology. Specifically, it teaches the concepts of relational databases and the SQL program-
ming language. It teaches how to write queries against single and multiple tables, manipulate
data in tables, and create database objects. It also teaches how to use single row functions to
customize output, use conversion functions and conditional expressions based on TESDA
Training Regulations.
Objectives:
1. The learners will able to use soring and restring data
I What is new?
ACTIVITY #1: TABLE DISPLAY
Direction: Study the table below and observed what happened to the displayed output. Ex-
plain the changes. Also, answer the following questions:
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 28
Output Table #1
____________________________________
____________________________________
____________________________________
____________________________________
____________________________________
____________________________________
Output Table #2
____________________________________
____________________________________
____________________________________
____________________________________
____________________________________
____________________________________
Output Table #3
____________________________________
____________________________________
____________________________________
Output Table #4
____________________________________
____________________________________
____________________________________
Output Table #5
____________________________________
____________________________________
____________________________________
____________________________________
D What do I know?
ACTIVITY #2: FILL IN THE BOX
Direction: Guess the term based on its definition. Fill the missing letters in the box provided.
4. An order when they are arranged from the largest to the smallest number.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 29
D What is in?
D What is it?
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 30
Code1: SELECT FIRSTNAME, LASTNAME FROM EMPLOYEE ORDER BY 1;
Explanation: Getting all first name and surname of each employee. The list is sorted from A
to Z (ascending) based on the first column in the output table which is the first name.
Explanation: Getting all first name and last name of each employee. The list is sorted in
ascending order based on the first name.
Explanation: Getting all the first name and last name of each employee. The list is sorted in
descending order based on the first name.
Explanation: Getting all the department and first name of each employee. The list is sorted in
ascending order based on their department. Incase that there is a first name with the same
department, you will sort the first name in descending order (for those with the same
department only)
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 31
ACTIVITY #5: WHAT DO I LOOK?
DIRECTION: Based on the SQL code, display the output table using the employee table
in the activity #1:
1. SELECT EMP_NO, DEPARTMENT, SALARY FROM EMPLOYEE ORDER BY SALARY DESC;
———
RELATIONAL OPERATOR AND LOGICAL OPERATOR
Relational Operator - compares the value of left operand to the right operand.
Example 5 > 6
Not Accepted if the sequence of the expression using relational operator is like 64 > age > 16
or Operand Operator Operand Operator Operand. It must Operand Operator Operand like
the example above or in the table.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 32
Logical Operator evaluates the expression whether the condition is either true or false. There
are 3 basic logical operator used in programming: AND, OR and NOT. The result of these oper-
ator is either true or false based on the truth table.
OR Operator
If one of the
value is TRUE,
the result is
TRUE
NOT (True)
False
Based on the given operator since previous module, we have already 3 operators to be used in
the programming namely: Arithmetic, Relational and Logical Operator. This operator is used
to restrict data in the output table. Then we have additional order of operator to evaluate the
given expression.
1. Evaluate the Arithmetic Operator (Follow the rules of order of operator)
2. Evaluate the Relational Operator (All operators have the same priority)
3. Evaluate the Logical Operator (Follow the rules of order of operator)
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 33
Example Expression:
Let X = 11 and Y = -3:
Expression: X - 3 * Y > X % 9 OR y + x - 2 <= x - y AND x / (y + 6) != x / y + 6
TRUE
BOOLEAN EXPRESSION
An evaluated expression that results either TRUE OR FALSE. Mostly of the Boolean
expression has relational operator. We all know that the result of relational operator and
logical operator when evaluates that result to Boolean value which TRUE or FALSE.
Example:
1. Create a Boolean expression that tells whether a person is a legal or not.
We all know that to determine if the person is a legal or not if he is 18 years old and above
based on his age. So the Boolean expression is:
AGE >= 18
2. Create a Boolean expression that tells whether a person is a male.
Male is an example of Sex, so the Boolean expression is:
SEX = “MALE”
3. Create a Boolean expression that needs whether his grade is between 75 and 80.
The numbers between 75 and 80 are 76, 77, 78, 79. So as you can there is a logical
operator indicate and that is the AND operator. When using the logical operator, you need
to use 2 relational operator. So the Boolean expression for that description is:
75 < grade AND grade < 80
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 34
ACTIVITY#5: BOOLEAN EXPRESSION
Direction: Create the Boolean Expression based on the given description. Write your answer
on the space provide after the number.
1. The Passing Grade
2. The Section is either Microsoft or Oracle
3. If the person is a teenager
Direction: Evaluate the expression below. Show your calculation steps and box your final
answer.
Let A = 9 and B = -2: NOT(A%4 <= A/B AND (A + (A-B) = A+A-B OR A*B > A * -1))
——————————————————————————————————————————————
WHERE CLAUSE
The where clause is a command where you are limiting the output of the display table based
on the given condition which is Boolean expression. You will add the where clause at the
SELECT statement after the FROM clause. The Boolean expression must be TRUE.
Syntax:
SELECT columnNames FROM tableName WHERE Boolean Expression;
Using this table:
Example #1:
Condition / Requirement:
List all the information of each employee that belongs to HR Department.
SQL Code:
SELECT * FROM EMPLOYEE WHERE DEPARTMENT = “HR”;
Output / Result:
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 35
Example #2:
Condition / Requirement:
List the employee number and last name of each employee that does not belong to HR
Department and with a salary below 20,000.
SQL Code:
SELECT EMP_NO, LASTNAME FROM EMPLOYEE WHERE DEPARTMENT != “HR” AND
SALARY < 2000;
Output / Result:
E What is more?
Direction: Study the table below. Write the correct SQL code based on the given condition.
1. List all the information of each male student. Sort the list by its LRN.
____________________________________________________________________________________________
2. List the name and strand of the student with failing grade.
____________________________________________________________________________________________
3. List the name and average grade of the student with passing grade.
____________________________________________________________________________________________
4. List the strand, name and the sex of each student that has a midterm grade of higher than
80. Sort the list by its strand and its name in descending order.
____________________________________________________________________________________________
____________________________________________________________________________________________
5. List the strand, name of each female student with line of 7 in final. Sort the list by its
strand in descending order.
____________________________________________________________________________________________
_________________________________________________________________________________________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 36
E What can I do?
2. List the name and strand of the student with failing grade.
3. List the name and average grade of the student with passing grade.
4. List the strand, name and the sex of each student that has a midterm grade of higher than
80. Sort the list by its strand and its name in descending order.
5. List the strand, name of each female student with line of 7. Sort the list by its strand in
descending order.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 37
A What I have learned?
1. Display all the information of your family member that is 20 years old and above.
2. Display the male family member’s name and your relationship to them and a
teenager. Sort the list based on your relationship in descending order.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 38
A What can I achieve?
ACTIVITY #9: WRITING THE SQL COMMAND USING YOUR OWN TABLE.
Direction: Based on the description on the activity #8. Write the SQL command. Write your
answer in the space provided.
1. _________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
2. ________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
Reflection
Direction: Write your personal insights about the lesson using the prompt below.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 39
MODULE 4: SINGLE ROW FUNCTION (SRF)
Performance Standard:
The learners independently apply the fundamentals of SQL using Oracle Database
technology. Specifically, it teaches the concepts of relational databases and the SQL program-
ming language. It teaches how to write queries against single and multiple tables, manipulate
data in tables, and create database objects. It also teaches how to use single row functions to
customize output, use conversion functions and conditional expressions based on TESDA
Training Regulations.
I What is new?
ACTIVITY #1: BEFORE AND AFTER EFFECTS
Direction: Using the text or characters, observed what happens next. Explain your answer in
the space provided.
38.4 39 6. ___________________________
38.4 38 7. ___________________________
38 38 8. ___________________________
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 40
D What do I know?
ACTIVITY #2: WHERE DO I BELONG?
Direction: Based on the changes happened in the activity #1, categorize what kind of function
occurred in the previous activity. Type only the number in each category, Separate each number
by asterisk.
CHARACTER BASED
NUMBER BASED
D What is in?
ACTIVITY #3: BASED ON THE EXPERIENCE
Direction: Based on the activity #1 and #2, how do you categorize each item. Explain your answer
in the space provided.
CATEGORY EXPLANATION
CHARACTER BASED
NUMBER BASED
D What is it?
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 41
Single row functions can be -
Case Conversion functions - Accepts character input and returns a character value. Functions
under the category are UPPER, LOWER and INITCAP.
UPPER function converts a string to upper case.
LOWER function converts a string to lower case.
INITCAP function converts only the initial alphabets of a string to upper case.
Character functions - Accepts character input and returns number or character value. Func-
tions under the category are CONCAT, LENGTH, SUBSTR, INSTR, LPAD, RPAD, TRIM and RE-
PLACE.
CONCAT function concatenates two string values.
LENGTH function returns the length of the input string.
SUBSTR function returns a portion of a string from a given start point to an end point.
INSTR function returns numeric position of a character or a string in a given string.
LPAD and RPAD functions pad the given string up to a specific length with a given character.
TRIM function trims the string input from the start or end.
REPLACE function replaces characters from the input string with a given character.
Date functions - Date arithmetic operations return date or numeric values. Functions under the
category are MONTHS_BETWEEN, ADD_MONTHS, NEXT_DAY, LAST_DAY, ROUND and TRUNC.
MONTHS_BETWEEN function returns the count of months between the two dates.
ADD_MONTHS function add 'n' number of months to an input date.
NEXT_DAY function returns the next day of the date specified.
LAST_DAY function returns last day of the month of the input date.
ROUND and TRUNC functions are used to round and truncates the date value.
Number functions - Accepts numeric input and returns numeric values. Functions under the
category are ROUND, TRUNC, and MOD.
ROUND and TRUNC functions are used to round and truncate the number value.
MOD is used to return the remainder of the division operation between two numbers.
ABS returns the absolute value of numeric expression.
CEIL returns the smallest integer value that is not less than passed numeric expression
FLOOR returns the largest integer value that is not greater than passed numeric expression.
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 42
SQL CODE #1 (CASE CONVERSION and CHARACTER FUNCTION):
SELECT PRES_ID , INITCAP(NAME), UPPER(NAME), LOWER(NAME), CONCAT(PRES_ID, NAME), LENGTH(NAME), SUBSTRING(NAME, 2,4) , INSTR
(NAME, “o”, 2), LFAD(NAME, 5, “*”), RFAD(NAME, 3, “#@”), REPLACE(NAME, “a”, “@”) FROM PRESIDENT;
OUTPUT TABLE:
PAGE 43
MULTIPLE ROW FUNCTION / AGGREGATE FUNCTION
Oracle aggregate functions calculate on a group of rows and return a single value for each group.
The aggregate functions together with the GROUP BY clause. The GROUP BY clause divides the
rows into groups and an aggregate function calculates and returns a single result for each group.
If you use aggregate functions without a GROUP BY clause, then the aggregate functions apply to
all rows of the queried tables or views.
You can use the aggregate functions in the HAVING clause to filter groups from the output based
on the results of the aggregate functions.
Oracle aggregate functions can appear in SELECT lists and ORDER BY, GROUP BY,
and HAVING clauses.
SQL Code:
SELECT ROLE, AVG(KDA), MAX(KILLS) FROM MATCH_HISTORY GROUP BY ROLE;
OUTPUT TABLE: EXPLANATION
1. GROUP THE ROW BY ROLE
2. GETTING THE AVERAGE OF ALL
KDA PER ROLE (AVG)
3. GETTING THE HIGHEST KILL
PER ROLE (MAX)
SQL Code:
SELECT ROLE, COUNT(KDA), SUM(KILLS) FROM MATCH_HISTORY GROUP BY ROLE
ORDER BY 3 DESC;
EXPLANATION
OUTPUT TABLE:
1. GROUP THE ROW BY ROLE
2. GETTING HOW MANY DATA PER ROLE
(COUNT)
3. GETTING THE TOTAL KILLS PER ROLE
(SUM)
4. SORT BY HIGHEST SKILL IN HIGHEST TO
LOWEST
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 44
SQL Code:
SELECT NAME, COUNT(KILLS), AVG(KDA), MIN(DEATH) FROM MATCH_HISTORY GROUP
BY NAME HAVING MIN(DEATH) < 3;
OUTPUT TABLE:
SQL Code:
SELECT NAME, COUNT(KILLS), AVG(KDA), MIN(DEATH) FROM MATCH_HISTORY GROUP
BY NAME HAVING MIN(DEATH) < 3;
OUTPUT TABLE:
E What is more?
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 45
E What can I do?
ACTIVITY #6: MOBILE LEGEND TABLE
DIRECTION: Based on the table in the activity #5, identify the output table of the following code.
1. SELECT MATCH_ID, NAME, ROLE, ADD_MONTH(DATE, 15) FROM MATCH_HISTORY;
2. SELECT NAME, ROLE, ROUND(KDA,0) FROM MATCH_HISTORY ORDER BY 3, 2 DESC;
3. SELECT ROLE, COUNT(ROLE), MAX(KDA) FROM MATCH_HISTORY WHERE STATUS = “WIN”
OR DATE = “10/23/2020” GROUP BY ROLE;
4. SELECT NAME, MAX(KILL), MIN(DEATH) FROM MATCH_HISTORY WHERE MATCH_ID <= 50
GROUP BY NAME;
5. SELECT ROLE, AVG(KILL), ROUND(AVG(KDA),2) FROM MATCH_HISTORY GROUP BY ROLE
HAVING AVG(KILL) > 2;
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 46
References Module 1-4
WEBSITES
MODULE 1 PART 1
[1]https://news.codecademy.com/what-is-computer-programming/
[2] https://www.diffen.com/difference/Data_vs_Information
[3] https://www.tutorialspoint.com/basics_of_computers/
basics_of_computers_number_system.htm
[4] https://www.researchgate.net/post/
Why_do_we_need_various_number_base_conversions_number_system_conversions_eg_octal_t
o_hexadecimal2
[5] https://sites.google.com/a/esusdstudents.org/pierceapcsp/bytes-and-file-si
MODULE 1 PART 2
[1] https://www.tutorialride.com/dbms/sql-data-definition-language-ddl.htm
[2] https://www.tutorialride.com/dbms/sql-data-manipulation-language-dml.htm
[3] https://www.tutorialride.com/dbms/sql-data-retrieval-language-drl.htm
MODULE 2
[1] https://blog.matesic.info/post/sql-for-beginners-NULL
[2] https://www.bouraspage.com/repository/algorithmic-thinking/what-is-the-precedence-of-
arithmetic-operators#:~:text=Arithmetic%20operators%20follow%20the%20same,and%
20subtraction%20are%20performed%20last.
[3] https://techterms.com/definition/string
MODULE 4
[1] https://www.tutorialspoint.com/sql_certificate/using_single_row_functions.htm
[2] https://www.oracletutorial.com/oracle-aggregate-functions/
BOOKS
COUCHMAN, JASON (2001). ORACLE: OCP Introduction to Oracle9i: SQL Exam Guide.
United States of America: The McGraw Companies. 20-27 (Module 1 Part 2)
COUCHMAN, JASON (2001). ORACLE: OCP Introduction to Oracle9i: SQL Exam Guide. Unit-
ed States of America: The McGraw Companies. 29-35 (Module 2)
COUCHMAN, JASON (2001). ORACLE: OCP Introduction to Oracle9i: SQL Exam Guide.
United States of America: The McGraw Companies. 56 - 65. (Module 3)
SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 47
PAGE 48 SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON
MODULE #1 PART 1 ACTIVITY #2: JUMBLED LETTER
ACTIVITY #1: DATA VS INFORMATION 1. ALIAS
1. Data 2. 2. CONCATENATION
Information 3. OPERATOR
2. Information 4. NULL
Data
5. DISTINCT
3. Data
ACTIVITY #3: BASIC OPERATOR
Information
1. 10
ACTIVITY #2: PRE-ASSESSMENT
2. 32
1. Binary
3. 11
2. Decimal
3. ASCII Code
4. Nibble MODULE 3
5. Bit ACTIVITY #1 TABLE DISPLAY
ACTIVITY #3: TRUE OR FALSE 1. EMP_NO, LASTNAME, FRISTNAME, DEPARTMENT, SALA-
RY
1. False
2. False 2. 6
3. True 3. 5
4. False TABLE #1: The list is sorted by the department infor-
mation in ascending order
5. True
ACTIVITY #11: APPLICATION TABLE #2: The list is sorted based on their salary in
lowest to highest value
1. Money / Currency
TABLE #3: The list is an employee with a salary above
2. IP Address
20000
3. Digital Display
TABLE #4: The list is an employee belongs to HR de-
4. Color partment.
5. DVD, CD, etc.
TABLE #5: The list is an employee belongs to HR de-
6. Flash Disk, etc. partment and sorted by first name
7. External Hard Drive, etc. in ascending order
ACTIVITY #2 FILL IN THE BOX
MODULE #1 PART 2
1. Limit 3. Restriction
ACTIVITY #1: DATA
2. Sort 4. Descending Order
1. Picture / Information about Users / Videos
ACTIVITY #5 BOOLEAN EXPRESSION
2. Videos
1. Grade >= 75
3. Pictures
2. Section = “Microsoft” OR Section = “Oracle”
4. Videos
3. 12 < AGE AND AGE < 20
5. Information about Players, Game
Evaluation Result: TRUE
ACTIVITY #2: PRE ASSESSMENT
1. SQL
MODULE #4
2. Standard Query Language / Simple Query Language
ACTIVITY #1: BEFORE AND AFTER EFFECTS
3. Data Retrieval Language (DRL)
1. All characters become big letters.
4. Data Manipulation Language (DML)
2. All characters become small letters
5. Data Definition Language (DDL)
3. All the first character of each word become capitalized.
ACTIVITY #3: DATA TABLE
4. Show how many characters does the text has.
1. LRN, NAME, BIRTHDAY, ADDRESS
5. All letter ‘I’ becomes letter ‘e’.
2. 4
6. The value goes up by 1 (whole number)
3. 3
7. Removes decimal value
4. Students
8. Remains the same
9. All text becomes ‘*”
MODULE #2
10. The first 5 letters of the text becomes ‘*’
ACTIVITY #1: TOILET PAPER
You can see 3 different images of toilet paper: the first image
shows that there is plenty paper on the roll, the second image
shows that there is no paper on the roll and the third one, there
is no roll for the toilet paper: it means that there is no value.
Key Answer