Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
647 views

SJLSHS - Computer Programming - Oracle Database

1. The document discusses key concepts about data and computer programming, including the difference between data and information. It provides examples to illustrate the difference. 2. The document then discusses number systems used in computer programming like binary, decimal, octal, and hexadecimal. It explains how each system works and provides examples of converting between number systems. 3. Various activities are included for students to practice identifying data vs. information, true/false questions, and number system conversions.

Uploaded by

Edwin Lapat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
647 views

SJLSHS - Computer Programming - Oracle Database

1. The document discusses key concepts about data and computer programming, including the difference between data and information. It provides examples to illustrate the difference. 2. The document then discusses number systems used in computer programming like binary, decimal, octal, and hexadecimal. It explains how each system works and provides examples of converting between number systems. 3. Various activities are included for students to practice identifying data vs. information, true/false questions, and number system conversions.

Uploaded by

Edwin Lapat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Computer

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

I What do I need to know?


Content Standard:
The learners demonstrate an understanding of key concepts, underlying principles, and
core competencies in Computer Programming

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

Most Essential Learning Competencies:


1. Discuss the relevance of the course
2. Explain core competencies of Computer Programming

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?

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 called the computer language. __________
2. It is a number system that we used in everyday life. __________
3. It's a 7-bit character code where every single bit represents a unique character. __________
4. It is a term for 4 bits data. __________
5. It is the smallest unit of data. __________

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]

Binary Number System (Base 2)


The easiest way to vary instructions through electric signals is two-state system – on
and off. On is represented as 1 and off as 0, though 0 is not actually no signal but signal at a
lower voltage. The number system having just these two digits – 0 and 1 – is called binary
number system. Also, binary number system is called the computer language because the
computer only understand 0’s and 1’s. Each binary digit is also called a bit.
Binary number system is also positional value system, where each digit has a value expressed
in powers of 2, as displayed here.

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]

Octal Number System (Base 8)


Octal number system has eight digits – 0, 1, 2, 3, 4, 5, 6 and 7. Octal number system is
also a positional value system with where each digit has its value expressed in powers of 8. [3]

Hexadecimal Number System (Base 16)


Hexadecimal number system has 16 symbols – 0 to 9 and A to F where A is equal to 10,
B is equal to 11 and so on till F. Hexadecimal number system is also a positional value system
with where each digit has its value expressed in powers of 16. Hexadecimal Number System is
commonly used in Computer programming and Microprocessors. It is also helpful to describe
colors on web pages. Each of the three primary colors (i.e., red, green and blue) is represented
by two hexadecimal digits to create 255 possible values, thus resulting in more than 16
million possible colors. [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 1: Divide the number to its converting base.

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

Note: If the base is not indicated it is automatically based 10.

Conversion of Binary (2) into Octal (8) or Hexadecimal (16)


Example: 1011102 = _________8 1011102 = _________16
STEP#1: Group the binary digit per 3 digits (if it is to OCTAL) or 4 digits (if it is to HEXADECI-
MAL) starting from right to left. If the group is not by 3 or 4 digits, kindly add 0’s to make it
suitable before the last number.
Solution:
101 110 0010 1110
Question: Why group into 3 digits? 4 digits?
Answer: 23 = 8 (Octal) raised to 3 exponent
24 = 16 (Hexadecimal) raised to 4 exponent

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 €

Answer: 568 2E16

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

ACTIVITY#5: CONVERSION OF NUMBER SYSTEM.


Direction: Convert the following values to the indicated based. Show your solution in different
paper.
1. 132 → _____2 6. B0916 → _____
2. 199 → _____8 7. 110010102 → _____8
3. 253 → _____16 8. 110010102 → _____16
4. 10012 → _____ 9. BED16 → _____2
5. 7018 → _____ 10. 7738 → _____2

——————————————————————————————————————————————
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

Now a computer understands only numeric values,


whatever the number system used. So all charac-
ters must have a numeric equivalent called the al-
phanumeric code. The most widely used alphanu-
meric code is American Standard Code for Infor-
mation Interchange (ASCII). ASCII is a 7-bit code
that has 128 (27) possible codes [3],

Here is the equivalent ASCII Code for each special


characters and spaces:

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.

TEXT ASCII CODE BINARY NUMBER


Computer 67 111 109 112 117 116 101 114 1. ?
12 JavA 2. ? 3. ?

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]

ACTIVITY #7: BYTES


Direction: Convert the following. Express your answer in scientific notation.
1. 20 b = ____ B
2. 6723 KB = _____ GB
3. 5.32 TB = ______ Mb
4. 163.67 KB = ____ Bits
5. 932 KB = ____ Nimble

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)

DECIMAL BINARY OCTAL HEXADECIMAL

1. __________________ 11111001 2. __________________ F9

999 3. __________________ 4. __________________ 3E7

5. __________________ 6. __________________ 175316 7. __________________

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) .

BINARY NUMBER TEXT

01000100 01100101 01000001 01110100 00110010 1. _________________________

01000011 01101100 01100001 01110011 01110011 01010010


2. _________________________
01101111 00110000 01101101

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?
___________________________________________________________________________________________

A What I have learned?


ACTIVITY#10: THE IMPORTANCE
Direction: You are going to construct a persuasive essay about “The Importance of Number
System in Computer Programming”. You will be graded by the given Rubric below.

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

I What do I need to know?


Content Standard:
The learners demonstrate an understanding of the principles and concepts in demon-
strating knowledge of fundamentals of SQL using Oracle Database technology.

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.

Most Essential Learning Competencies:


1. Use DDL Statements to Create Tables in accordance with PL/SQL framework
2. Add new Rows to a Table in accordance with PL/SQL framework
3. List capabilities of SQL SELECT statements in accordance with PL/SQL framework
4. Generate report of data from the output of a basic SELECT statement in accordance
with PL/SQL framework

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.

ACTIVITY #1: DATA


Direction: Identify what kind of data (file) used in different social media platform.
1. Facebook _____________
2. YouTube _____________
3. Instagram _____________
4. Tiktok _____________
5. Mobile Legend _____________

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?

ACTIVITY #3: DATA TABLE


Analyze the table below and answer the following questions.

1. What are the column names in the table?____________________________________________


2. How many columns is/are presented in the table? ___________________________________
3. How many rows is/are presented in the table? _______________________________________
4. What is the table all about? _________________________________________________________

D What is it?

ACTIVITY #4: READING ACTIVITY


Read and understand the ideas and concept being presented.
A database is stored as a file or a set of files. The information in these files may be broken
down into records, each of which consists of one or more fields. A database consists of tables,
each of which has columns and rows. Each row (called a tuple / record) is a data set that ap-
plies to a single item. Each column (field) contains characteristics that describe the rows;
these columns are the attributes. A database attribute is a column name and the content of
the fields under it in a table.

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.

Basic Data Types


1. int - stands for Integer, the value must be a whole number.
2. float - the value must be a number with decimal value.
3. Date - if the value is date with a format of “YYYY-MM-DD”
4. varchar(length) - the value must be a character, the length must be specify on how many
characters the data has.

Data Definition Language (DDL)


It is a language used for defining and modifying the data and its structure.
It is used to build and modify the structure of your tables and other objects in the database.

DDL commands are as follows:


1. CREATE 3. ALTER 5. TRUNCATE
2. DROP 4. REMOVE

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.

The syntax for CREATE command is:


CREATE TABLE <table_name> WHERE AS:
N in the column and datatype means that you have many
column in one table. It is up to you how many column is
(
needed to your table.
ColumnName1 datatype1,
CREATE TABLE - command on creating table.
ColumnName2 datatype2,
<table_name> - specify the is the name of the table
ColumnName3 datatype3,
ColumnName - Name of the Column

Datatype - what kind of data does the column have.
ColumnNameN datatypeN
);

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.

Data Manipulation Language (DML)


It is a language used for selecting, inserting, deleting and updating data in a database.

DML commands are as follows:


1. INSERT
2. UPDATE
3. DELETE
DML performs read-only queries of data.
In this module, we are focusing about inserting data in our table (Basic only). On the
previous activities, you are already created the table but there is no data yet.

Syntax for INSERT command:


INSERT INTO <table_name> VALUES (data1, data2, … , dataN);
Where as:
INSERT INTO - means we will added new row of information in the table.
<table_name> - location where we will add the new row of information.
VALUES - indicate the next information is the data value for each row.
DATA - specify the value of each column name must be enclosed with double quotation
(“) per data with it is date or varchar datatype and separated by comma (,).

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. _________________________________________________________________________________________

Data Retrieval Language (DRL)


It is language used to retrieve or get the necessary table in a table. It is used to make reports
you need in the presentation. It helps you analyzed the needed information. There are only 1
command in DRL and that is the SELECT command:
The basic syntax of SELECT command:
SELECT columnName1, columnName2, …, columnName3 FROM <tableName>;
Where as:
SELECT - specify what column you need that contains the data you want to see.
columnName - in what column does your data located.
FROM - specify what table does your data being retrieved.
tableName - name of table where the data is retrieved.

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:

ACTIVITY #6: OUTPUT TABLE


Direction: Identity the output of each code in retrieving data in the table used in Activity #3.
1. SELECT LRN, ADDRESS FROM STUDENT;
2. SELECT ADDRESS, NAME, BIRTHDATE FROM STUDENT;

E What is more?

ACTIVITY #7: SUMMATIVE TEST


Direction: Study and analyze the table above, write the SQL command or code for each re-
quirement. Write your answer in the spaced provided.

1. Write the SQL Command for creating the above table.


____________________________________________________________________________________________
2. Write the SQL Command for inserting the information of each row in the table.
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
3. Write the SQL command on how to obtain all the information on table.
____________________________________________________________________________________________
4. Write the SQL command that shows only the name of each hero.
____________________________________________________________________________________________
5. Write the SQL command that shows only the role, name and price of each hero.
____________________________________________________________________________________________

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.

A What I have learned?


ACTIVITY #9: MODIFIED TRUE OR FALSE
Direction: Read and analyze each statement carefully. Identify whether the statement is cor-
rect or not. If the statement is correct, write TRUE and if the statement is wrong, change the
BOLD word/s to make the statement correct.
1. SQL stands for Simple Query Language. ________________________________________________
2. Database is a physical storage used to store different kind of data. _______________________
3. DRL is used for creating and modify table entity. _________________________________________
4. The other term for row is record. _________________________________________________________
5. The number of records indicate how many information stored in the database. ____________
6. DML is used on modifying the data in the table. __________________________________________
7. All of the website has its own database. _________________________________________________
8. Data Storage can store ultra-big size of data. _____________________________________________
9. SQL is case insensitive. _________________________________________________________________
10. DDL is used to get the needed data in the table. _________________________________________

A What can I achieve?


ACTIVITY #10: INFO ABOUT HERO TABLE
Based on the table in the activity #7 and answer the following questions.
1. What are the attribute in the table?____________________________________________
2. How many fields is/are presented in the table? ___________________________________
3. How many record is/are presented in the table? _______________________________________
4. What is the table all about? _________________________________________________________
5. Is it possible to have no any value in a record on one field? Explain your answer: _________
____________________________________________________________________________________________

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

I What do I need to know?


Content Standard:
The learners demonstrate an understanding of the principles and concepts in demon-
strating knowledge of fundamentals of SQL using Oracle Database technology.

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.

Most Essential Learning Competencies:


1. Use arithmetic expressions and NULL values in accordance with PL/SQL framework
2. Describe concatenation operator, literal character strings, alternative quote operator,
and the DISTINCT keyword in accordance with PL/SQL framework
3. Implement column aliases are in accordance with PL/SQL framework .

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 ( +, -, *, /, %)

 Relational / Comparison Operators (>, <, >=, <=, !=, =)

 Logical Operators (NOT, OR, AND)

Arithmetic Operator
Assume that the variable X holds 7 and variable Y holds 3.

Operator Symbol Description Example Result


Addition + Adds values on either side of the operator. X+Y 10

Subtraction - Subtracts right hand operand from X-Y 4

Multiplication * Multiplies values on either side of the operator. X*Y 21


Division / Divides left hand operand by right hand operand. X/Y 2
Divides left hand operand by right hand operand
Modulo % X%Y 1
and returns remainder.

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.

ACTIVITY #5: Arithmetic Operator and NULL


Direction: Using the EMPLOYEE table above, write the SQL command / code and display
the output table.
Requirement: List the Firstname and the annual GSIS contribution of each employee.
Note: The GSIS contribution is the 2% of the annual salary.
Code: _________________________________________________________________________________
Output Table:

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.

Using the EMPLOYEE table on the previous page,


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 AS “TAX” FROM EMPLOYEE;
Output Table:

ACTIVITY #6: CONCATENATION AND ALIASING


Direction: Using the EMPLOYEE table, write the SQL command of the following statement
and display the output table.
1. List all employee number, their fullname and their salary per day of each employee. The
format for fullname is Lastname, Firstname and there is a 20 working days in a month.
Name the column correctly based on the given data.
Code: _____________________________________________________________________________________
_____________________________________________________________________________________
Output Table:

SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON PAGE 24
E What is more?

ACTIVITY #7: WHAT IS IN THE TABLE?


Direction: Study the table on the previous post. Answer the following question.
1. What is the table all about? __________________________________________________________
2. How many attributes presented in the table? Enumerate them. ________________________
_________________________________________________________________________________________
3. How many null values in CHAMP_ID? ___________________________________________________
4. How many null values in the ROLE2? ___________________________________________________
5. Is the date presented in the default format? Explain. ____________________________________
_________________________________________________________________________________________

E What can I do?


ACTIVITY #8: CODING SQL STATEMENT

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

1. Create the table presented in the activity #7.

___________________________________________________________________________________________

2. Show the role1 without any duplicate.

___________________________________________________________________________________________

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

Rubrics: 10 pts - Creativity


10 pts - Content

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

I What do I need to know?


Content Standard:
The learners demonstrate an understanding of the principles and concepts in demon-
strating knowledge of fundamentals of SQL using Oracle Database technology.

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.

Most Essential Learning Competencies:


1. Sort and restrict data.

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:

1. What are the attributes? _______________________________________________________________


2. How many records are in the table? ____________________________________________________

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.

1. A restriction on the size or amount of something permissible or possible.

2. The arrangement of data in a prescribed sequence.

3. Put a limit on; keep under control.

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?

ACTIVITY #3: W Diagram


Direction: Based on the activity #1, write the concepts regarding the similarities and
differences of sorting and restring data.

D What is it?

ACTIVITY #4: READING ACTIVITY


ORDER BY CLAUSE
Database table maintains the data in the order that the database system stores it internally,
which is unpredictable in nature. In any database system contains set of rows of data (record)
which sets are not ordered or arranged. To arrange / sort the display of your data in the
columns, you have to issue the ORDER BY command. You can sort data in ascending or
descending order of any column you specify. You will include the ORDER BY command at the
end of SELECT statement. Default order is in ascending order.
The syntax of SELECT statement with ORDER BY clause:
SELECT columnName1, columnName2, …, columnName3 FROM <tableName> ORDER
BY columnName/columnNumber ASC or DESC;

Application on Different Data Type


Ascending Descending
1. varchar lowest to highest, A to Z highest to lowest, Z to A
2. int / float lowest to highest highest to lowest
3. date oldest to newest newest to oldest

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.

Code2: SELECT FIRSTNAME, LASTNAME FROM EMPLOYEE ORDER BY FIRSTNAME;

Explanation: Getting all first name and last name of each employee. The list is sorted in
ascending order based on the first name.

Code3: SELECT FIRSTNAME, LASTNAME FROM EMPLOYEE ORDER BY FIRSTNAME DESC;

Explanation: Getting all the first name and last name of each employee. The list is sorted in
descending order based on the first name.

Code4: SELECT DEPARTMENT, FIRSTNAME FROM EMPLOYEE ORDER BY DEPARTMENT,


FIRSTNAME DESC;

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;

2. SELECT LASTNAME, SALARY FROM EMPLOYEE ORDER BY 2;

3. SELECT DEPARTMENT, SALARY FROM EMPLOYEE ORDER BY 1 DESC, SALARY ASC;

———
RELATIONAL OPERATOR AND LOGICAL OPERATOR
Relational Operator - compares the value of left operand to the right operand.
Example 5 > 6

Left Operand Symbol Right Operand

Let A has a value of 9 and B has 5.


Then, A = 9 and B = 5

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.

AND Operator NOT Operator


Change the
If one of the
Value from
value is FALSE,
True to False
the result is
(Vice Versa)
FALSE

OR Operator

If one of the
value is TRUE,
the result is
TRUE

HIERARCHY OF LOGICAL OPERATORS


1 - AND, 2 - OR, 3 - NOT
From Left to Right
Example
NOT (False AND False OR (True AND True))

NOT (False AND False OR True)

NOT (False OR 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

Substitute the value of X and Y


 11 - 3 * -3 > 11 % 9 OR –3 + 11 - 2 <= 11 - (-3) AND 11 / (-3 + 6) != 11 / -3 + 6

 11 + 9 > 2 OR 8 - 2 <= 11 + 3 AND 11 / 3 != -3 + 6

 20 > 2 OR 6 <= 14 AND 3 != 3

 TRUE OR TRUE AND FALSE The highlighted operand and operator


is evaluated per line based on the
rules of order in operator.
 TRUE OR FALSE

 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?

ACTIVITY #6: WRITING SQL COMMAND

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?

ACTIVITY #7: DISPLAYING THE RESULT


Direction: Based on the table above, display the output table or the result of each given
description or 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. 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?

ACTIVITY #8: OUTPUT TABLE USING YOUR OWN TABLE.


Direction: Complete the table below based on the information on your family mem-
bers. You need at least 8 family members to complete the data. It can be your sister,
brother, mother, father, cousin, uncle, auntie and grandparents EXCEPT your own
information. Display the result based on the given description.

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)

I What do I need to know?


Content Standard:
The learners demonstrate an understanding of the principles and concepts in demon-
strating knowledge of fundamentals of SQL using Oracle Database technology.

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.

Most Essential Learning Competencies:


1. Define the Single Row Function in accordance with PL/SQL framework.
2. Manipulate strings using character function and numbers with the ROUND, TRUNC,
and MOD functions in accordance with PL/SQL framework

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.

BEFORE AFTER OBSERVATION

sAn Jose LitEx SAN JOSE LITEX 1. ___________________________

sAn Jose LitEx san jose litex 2. ___________________________

sAn Jose LitEx San Jose Litex 3. ___________________________

sAn Jose LitEx 14 4. ___________________________

MISSISSIPPI MESSESSEPPE 5. ___________________________

38.4 39 6. ___________________________

38.4 38 7. ___________________________

38 38 8. ___________________________

COMPUTER ******** 9. ___________________________

COMPUTER *****UTER 10. __________________________

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?

ACTIVITY #4: READING ACTIVITY


Oracle SQL supplies a rich library of in-built functions which can be employed for various
tasks. The essential capabilities of a functions can be the case conversion of strings, in-string or
substring operations, mathematical computations on numeric data, and date operations on date
type values. SQL Functions optionally take arguments from the user and mandatorily return a
value. On a broader category, there are two types of functions :-
Single Row functions - Single row functions are the one who work on single row and return one
output per row. For example, length and case conversion functions are single row functions.
Multiple Row functions - Multiple row functions work upon group of rows and return one result
for the complete set of rows. They are also known as Group Functions.

Single Row Functions


Single row functions can be character functions, numeric functions, date functions, and conver-
sion functions. Note that these functions are used to manipulate data items. These functions re-
quire one or more input arguments and operate on each row, thereby returning one output value
for each row. Argument can be a column, literal or an expression. Single row functions can be
used in SELECT statement, WHERE and ORDER BY clause. [1]

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.

STUDY THE TABLE BELOW:

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:

SQL CODE #2 (DATE and NUMERIC FUNCTION)


SELECT PRES_ID, NAME, STARTING_DATE, ADD_MONTH(STARTING_DATE, 7), NEXT_DAY(STARTING_DATE), LAST_DAY(STARTING_DATE), CEIL
(TERM), FLOOR(TERM), ROUND(TERM, -1), ROUND(TERM, 1), TRUNC(TERM, 1), TRUNC(TERM, 0) FROM PRESIDENT;

SAN JOSE-LITEX SENIOR HIGH SCHOOL CREATED BY SIR ALDRINE C. QUIOZON


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.

STUDY THE MATCH HISTORY TABLE BELOW:

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?

STUDY THIS MATCH_HISTORY BELOW FOR THE REMAINING ACTIVITIES.

ACTIVITY #5: BACK TO BASIC


DIRECTION: Identify the following:
1. How many records in the table?
2. What is the name of the table?
3. What are the attributes represented in the table?
4. How many tuples in the table?
5. Is there a null value in the table?
6. How many fields in the table?

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;

A What I have learned?

ACTIVITY #7: DATABASE REVIEWER


DIRECTION: Create 3-5 pages reviewer regarding what you have learned in this module. Use
stabilo to highlight the important term. Use the family table you’ve created and use it as your
example. You can give as many as you can example for lesson you’ve write. Don’t’ forget to give the
condition, SQL code and the output table per example.

A What can I achieve?

ACTIVITY #8: REFLECTION


DIRECTION: Create an one-page essay on what you have learned and how it affects you on
building or creating a software, games, websites or applications. To express your ideas clearly, you
can use whatever language you want.

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)

PEPITO, COPERNICUS P. (2011), Introduction to Oracle Database - 11g Programming.


Mandaluyong City, Manila, Philippine: National Book Store. 58 - 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

You might also like