Managing Database Systems.pptx
Managing Database Systems.pptx
SYSTEMS
ICSC0413 – DATABASE MANAGEMENT SYSTEM
A.Y. 2024 – 2025
INSTRUCTOR: KHRIS VILLEGAS
OBJECTIVES
At the end of this course packet, you will be able to:
• Data warehouse refers to the process of collecting and consolidating data into one
common database. This is where the data can be stored for valuable data mining.
• Data mining refers to the process of extracting valuable data from the databases.
The advantage of using data mining will depend on the data collected and
consolidated in the data warehouse.
MANAGING DATABASE SYSTEMS
Set Operators
• These are used to combine the results of multiple queries into one
result set. Queries with SET operators are referred to as compound
queries. In these kind of queries, database users can combine multiple
queries by adding, subtracting or intersecting their results.
MANAGING DATABASE SYSTEMS
• The query can be issued to display the current and previous job titles with
the corresponding department number of all employees.
Example:
SELECT employee_id, department_id FROM Employees
UNION
SELECT employee_id, department_id FROM JobHistory;
MANAGING DATABASE SYSTEMS
• Unlike UNION, the UNION ALL records from both queries including
duplicates. Since the output is not sorted by default, an ORDER by CLAUSE
can be included in the query to sort the records according to the desired
arrangement.
Example:
SELECT employee_id, department_id FROM Employees
UNION ALL
SELECT employee_id, department_id FROM JobHistory
ORDER BY employee_id;
MANAGING DATABASE SYSTEMS
• The CUBE and ROLLUP operators are specified in the GROUP BY clause of
a SELECT statement. These operators are extensions of the GROUP BY
clause that are used to generate super aggregate rows by cross-referencing
columns.
• ROLL UP. It is used to produce a set of results containing the regular
grouped rows and subtotal rows.
• CUBE. It is used to generate results containing the records from ROLL UP
and cross-tabulation records. It groups selected records based on the values of
all possible combinations of expressions and returns a single record of
summary information for each group.
MANAGING DATABASE SYSTEMS
SYNTAX;
SELECT [column,] group_function (column)…
FROM table
[WHERE condition]
[GROUP BY [ROLL UP | CUBE] group_by_expression]
[HAVING having_expression]
[ORDER BY column];
MANAGING DATABASE SYSTEMS
GROUPING FUNCTION:
Example
• For department_id less than 20, display the total salaries for every job_id
within a department and get the total of all the salaries within each
department. Include a column to show how the summary values are
computed.
SELECT department_id, SUM (monthly_salary)
GROUPING (department_id) GRT_DEPT
FROM employees
WHERE department_id<20
GROUP BY ROLLUP (department_id);
QUESTIONS ?
THANK YOU ☺