0% found this document useful (0 votes)
12 views13 pages

CST 2355 - Database Systems. - Week 12 (Updated)

The document covers topics related to database systems, specifically focusing on PL/SQL triggers, packages, and an introduction to data warehousing. It explains the types of database triggers, their execution conditions, and the advantages of using PL/SQL packages for modularity and performance. Additionally, it distinguishes between Online Transaction Processing (OLTP) and Online Analytical Processing (OLAP) databases, highlighting their characteristics and purposes.

Uploaded by

vy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views13 pages

CST 2355 - Database Systems. - Week 12 (Updated)

The document covers topics related to database systems, specifically focusing on PL/SQL triggers, packages, and an introduction to data warehousing. It explains the types of database triggers, their execution conditions, and the advantages of using PL/SQL packages for modularity and performance. Additionally, it distinguishes between Online Transaction Processing (OLTP) and Online Analytical Processing (OLAP) databases, highlighting their characteristics and purposes.

Uploaded by

vy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

CST 2355 – Database

Systems
Week 12
Topics Covered:
• Oracle
• PL/SQL Triggers & Packages
• Introduction to Data Warehousing

Copyright © 2021 Algonquin College. All rights reserved. 2


Database Trigger…Continue
• A Database Trigger is a PL/SQL Block which is associated with a table, view, schema or the entire
database.
• A Trigger is never called (i.e. Executed), It Executes Implicitly (Automatically) whenever a particular
event takes place. Hence, Triggers may be used to perform automated task based on certain events.
Database Triggers are of two types:
1. Schema Level Trigger: Based on a particular object (table/view) in a schema
2. System Trigger: Based on the entire database.
When creating a trigger, we must decide on three things:
• Trigger Time - Trigger time decides whether a trigger is to be executed BEFORE or AFTER an EVENT
• Trigger Event – Trigger EVENT is the EVENT upon which the trigger should be executed. EVENT could
be INSERT, UPDATE, DELETE, INSTEAD OFF, LOGON, LOGOFF, STARTUP, SHUTDOWN, etc.
• Trigger Type – Two types of Triggers are possible. Row Level & Statement Level. A Row Level Trigger
executes once for each record affected by the EVENT. A Statement Level Trigger executes only once
irrespective of the records affected by the EVENT.
• Triggers may not contain DCL (commit/rollback) statement.
Demo Triggers Posted on Brightspace… 3
Instead Of Trigger
• A View consisting of Group Function, Group by Clause, Join Condition,
etc. is called a complex view.
• DML Operations are not allowed on a Complex view.
• To Perform DML operations through a complex view on the base
table, we may create an INSTEAD of Trigger on the complex view.
• Instead of Trigger are created on Views and allows performing DML
operation on the complex view by redirecting them on the base
tables.
• Instead of Triggers can only be ROW LEVEL Triggers.

Copyright © 2021 Algonquin College. All rights reserved. 4


PL/SQL Packages
• Packages are used to bundle together group of logically related Sub-Programs.
• A Package Consist of two parts - Package Specification & Package Body, Both of
which are stored independently in the Data Dictionary.
• The Package Specification must first be created and only then a body is created.
• The sub programs (i.e. procedure/functions) mentioned in the package
specification are PUBLIC sub programs. The sub programs described in the
package body, but not mentioned in the specification are PRIVATE sub
programs.
• A Package itself can’t be invoked, parameterizes or nested. Sub Programs in a
package are invoked, parameterized or nested.
• When one Sub-Program from the packages is called, the entire package is
loaded in the memory providing faster access to other Sub-Programs.

Copyright © 2021 Algonquin College. All rights reserved. 5


Advantages of Packages
• Modularity – Each Application Module could have one or more related
PL/SQL package in the database.
• Encapsulation – Can implement concept of Public/Private sub-programs
through packages.
• Overloading – We can implement Function Overloading in a package by
declaring multiple functions with the same name but different parameter list.
• Better Performance – When one sub-program from the package is
invoked/called, the entire package is loaded in the memory providing faster
access to the rest of the sub-programs.

Demo Package Example Posted on Brightspace…

Copyright © 2021 Algonquin College. All rights reserved. 6


Introduction to Data Warehousing

Databases

OLTP OLAP

Depending upon the use of data, Databases can be classified as Online


Transaction Processing (OLTP) or Online Analytical Processing (OLAP).
DML vs SELECT
Dept Emp
Deptno Dname Loc Empno Ename Job Sal Comm Deptno
10 IT Kanata 101 Smith Tech 5000 0 10
20 Sales Ottawa 102 King Admin 3000 500 20
30 R&D Dallas 103 Marry Tech 5000 0 10

Dept_Emp
Empno Ename Job Sal Comm Deptno Dname Loc

101 Smith Tech 5000 0 10 IT Kanata

102 King Admin 3000 500 20 Sales Ottawa

103 Marry Tech 5000 0 10 R&D Dallas

• A Normalized Database with many small tables is ideal for DML operations.
• A De-Normalized Database with few large tables is ideal for SELECT operations as it eliminates or decreases
JOINS.
Online Transaction Processing (OLTP)
Databases
OLTP Databases are designed to support transaction oriented
applications, such as bank’s ATM Machines, Airline’s Ticket Booking
website, etc. The Characteristics of OLTP are:
• Stores Current Data
• Records Routine / Daily Business Transactions
• Used by Internal (Employees) and External (Customers) Users
• Designed to suit insert, update, delete operations
• OLTP’s are the primary source of Data
Online Analytical Processing (OLAP) Databases

OLAP Databases are designed to support Analysis on large volumes of


data.
• Stores Current & Historic Data (Data of several years)
• Primary goal is to retrieve, analyze and report large volume of historic
data
• Used only by Internal (Employees) Users
• Designed to suit SELECT operations
• Day-To-Day Business does not depends on OLAP
OLTP OLAP
E.T.L

Costco.
Data Warehouse
Ontario Costco. - Canada

Costco.
Alberta DATA DATA
MART MART
Costco.
B.C OLAP & Data Mining
Key Terminologies

Data Warehouse is a large storage of data gathered from a wide


range of sources within a company and used to guide
management decisions.

Data Mart is a Subset of data warehouse. It Summarizes or highly


focuses on a portion of firm’s data for specific use. Typically
focuses on single subject or line of business
Data Mining &
OLAP
OLAP and data mining are used to solve different kinds of analytical
problems:

OLAP provides summary data and generates rich calculations. For


example, OLAP answers questions like "How many iPhones were sold in
Ottawa in last year ? Retailer wise Sales report of iPhones in Last year

Data mining is used to discover hidden patterns & relationships in large


databases and establish rules to predict future behavior. Data mining
answers questions like "Who is most likely to buy a Apple iPhone in the
next three months ?“ “What will be the gender and age group of these
buyers?”

You might also like