You are on page 1of 6

Instructions: 

 Provide your answer for the following questions:

 Define the following terms:

1. dynamic SQL

Dynamic SQL is an application, wherein it uses a dynamic commands (both flexible and
adaptable), which makes querying in the database more flexible. Dynamic SQL works by allowing the
application to create code before it is executed. This also allows to execute commands that is not
supported by static SQL (Dynamic SQL; Gibbs; Oracle, n.d.).

2. correlated subquery

Correlated subquery is a subquery that is dependent on the outer query. This type of query is
executed for each of the row executed by the outer subquery and can be independently executed (Geek
for Geeks, 2018; SQL Correlated Subqueries, 2020).

3. embedded SQL

Embedded SQL is a method used for embedding SQL statements in a programming language
like C++, Java, Python, and other high-level programming languages. This gives easy access to the
database and provides security to database transactions (Techopedia, 2011).

4. procedure

Procedures in SQL are often referred to as stored procedures. These are subprograms that can be
created and saved as database objects. Procedures are a group of SQL statements that is stored and
designed together to perform a specific task in order. This does not return a value if compared to a
function. Procedures can be used for quick querying, making simple reports, improving the database
design, security, and etc. (Choudary; Parahar, 2019).

5. join

Joins are a set of SQL statements that are used to compare and merge or combine the rows of
two or more tables formed upon the table’s related attributes (Kappagantula, 2020).

6. equi-join

Equi join is a type of join, wherein it contains an equality operator “=”. This only returns the
rows with having equivalent value for a specified column (Kappagantula; W3Reseource, 2020).

University of the East - Caloocan Page 1 of 6


College of Engineering – CpE Department
7. self join

Self join is a type of join, wherein the table is joined to itself, hence the name self join
(W3Reseource, 2020).

8. outer join

Outer joins are like inner joins, but this specific type of joins allows the return of matched and
unmatched rows of one or both of the two tables (W3Reseource, 2020).

9. function

Functions are set of instructions that can accept an input and return a certain value (Parahar,
2019).

10. Persistent Stored Modules (SQL/PSM)

Persistent Stored Modules or PSM is a part of the SQL standards for writing persistent store
modules. This allows us to store procedures in the database as database objects. PSM is a both the
combination of conventional statement like the while and ifs, and SQL. Its functions and procedures
were written in a simple-general purpose language. This gives capability to create and drop different
SQL modules, wherein the modules will exist and be stored as database objects unless dropped (Crate
Io, n.d.).

 When is an outer join used instead of a natural join?

In SQL, outer join is used when we wanted to compare, match, and get the rows of tables along with the
unmatched rows of only one or both of the tables being compared. Inner joins are used when we wanted to
compare, match, and get the rows of tables that are common to both of the tables. Outer joins have different
types giving the user a choice to return all the rows including the unmatched rows in the first table (Left
Outer Join), return the rows including the unmatched rows in the second table (Right Outer Join), and return
the unmatched rows in both of the tables (Full Outer Join) (Differen, n.d.).

 Explain the processing order of a correlated subquery.

An SQL correlated subquery executes one time for each record returned by the outer query. It is a
correlation between the number of times the subquery is executed with the number of records returned by
the outer query (Geeks for Geeks, 2018).

 Discuss the differences between triggers and stored procedures.

Triggers are a set of stored procedures that executes automatically based on events. Triggers, also, does
not accept any inputs and cannot have transaction statements inside, thus triggers does not return values. On
the other hand, stored procedures are a set of statements, which are intended to do specific tasks. Also,
stored procedures, compared to triggers, can be called explicitly by the user, can use transaction statements ,
thus accepts an input and returns a value (Shriv, 2020).

University of the East - Caloocan Page 2 of 6


College of Engineering – CpE Department
 lf two queries involved in a UNION operation contained columns that were data type
incompatible, how would you recommend fixing this?

This problem can be fixed by tricking the UNION operator with NULL. The idea of this SQL trick is to
use UNION operator to combine unrelated data. The combined dataset may be grouped further by a
common column(s) if any. By adding NULLs we can work-around the UNION requirement that all
SELECT statements must have the same number of columns with similar types. Using NULL makes the
columns of the table compatible to make it UNION compatible. The trick works with Oracle, Microsoft
SQL Server, MySQL, PostgreSQL and other relational databases that support SQL-92 standard (Case,
2018).

References:

Case, J. (2018, April 12). Is it possible to use SQL UNION with different columns (type and number) or do you

have to do the [Online Forum Post]. Quora. https://www.quora.com/Is-it-possible-to-use-SQL-UNION-

with-different-columns-type-and-number-or-do-you-have-to-do-the-trick-with-NULL-and-an-alias-to-

simulate-the-columns-similarities

Choudary, A. (2019, October 29). How to Create Stored Procedures in SQL? Edureka.

https://www.edureka.co/blog/procedures-in-sql/

Crate IO. (n.d.). Chapter 26 – PSM: Not just Persistent Stored Modules — SQL 99. Crate.Io. Retrieved May 26,

2021, from https://crate.io/docs/sql-99/en/latest/chapters/26.html

Differen. (n.d.). Inner Join vs Outer Join. Diffen. Retrieved May 28, 2021, from

https://www.diffen.com/difference/Inner_Join_vs_Outer_Join#:%7E:text=In%20SQL%2C%20a

%20join%20is,some%20dissimilar%20data%20from%20tables.

Dynamic SQL | Idera Glossary. (n.d.). Idera.Com. https://www.idera.com/glossary/dynamic-sql

GeeksforGeeks. (2018a, February 6). SQL Correlated Subqueries. https://www.geeksforgeeks.org/sql-

correlated-subqueries/

University of the East - Caloocan Page 3 of 6


College of Engineering – CpE Department
GeeksforGeeks. (2018b, February 6). SQL Correlated Subqueries. https://www.geeksforgeeks.org/sql-

correlated-subqueries/#:%7E:text=Correlated%20subqueries%20are%20used%20for,%2C

%20UPDATE%2C%20or%20DELETE%20statement.

Gibbs, M. (n.d.). Study.com | Take Online Courses. Earn College Credit. Research Schools, Degrees &

Careers. Study.Com. https://study.com/academy/lesson/what-is-dynamic-sql.html

Kappagantula, S. (2020, September 14). Understanding SQL Joins – All You Need To Know About SQL Joins.

Edureka. https://www.edureka.co/blog/sql-joins-types

Oracle. (n.d.). Dynamic SQL. Oracle.Com.

https://docs.oracle.com/cd/A87860_01/doc/appdev.817/a76939/adg09dyn.htm#:%7E:text=Dynamic

%20SQL%20is%20a%20programming,may%20be%20unknown%20at%20compilation.

Parahar, M. (2019, November 28). Difference between Function and Procedure. Tutorials Point. Com.

https://www.tutorialspoint.com/difference-between-function-and-procedure

Shriv, H. (2020, January 21). Difference between stored procedure and triggers in SQL. Tutorials Point.

https://www.tutorialspoint.com/difference-between-stored-procedure-and-triggers-in-sql#:

%7E:text=Stored%20procedures%20are%20a%20pieces,to%20do%20some%20specific

%20task.&text=On%20the%20other%20hand%2C%20trigger,run%20at%20the%20specific%20event.

SQL Corelated Subqueries. (2020, February 26). W3resource.

https://www.w3resource.com/sql/subqueries/corelated-subqueries-using-aliases.php

University of the East - Caloocan Page 4 of 6


College of Engineering – CpE Department
Techopedia. (2011, November 5). Embedded SQL. Techopedia.Com.

https://www.techopedia.com/definition/27342/embedded-sql

W3Reseource. (2020, February 26). SQL Equi join. https://www.w3resource.com/sql/joins/perform-an-equi-

join.php

W3Resources. (2020, February 26). Sql Full Outer Join. https://www.w3resource.com/sql/joins/perform-a-full-

outer-join.php

University of the East - Caloocan Page 5 of 6


College of Engineering – CpE Department
University of the East - Caloocan Page 6 of 6
College of Engineering – CpE Department

You might also like