Views & Triggers

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

flashcard set

Earn XP

Description and Tags

Last updated 11:21 AM on 5/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

14 Terms

1
New cards
View
A virtual table based on a SELECT query that is saved as an object in the database.
2
New cards
Base table
The underlying real table on which a view is based.
3
New cards
CREATE VIEW syntax
CREATE VIEW view_name AS [SELECT query];
4
New cards
Why are views dynamically updated
The virtual table is recreated on demand each time it is used, so changes to the base table appear immediately in the view.
5
New cards
Three benefits of views
(1) Basis for reports, (2) Security through aliased columns and hidden table names, (3) Filter rows so end-users don't see the full set.
6
New cards
Updatable view
A view that can update attributes in the base tables it is built from.
7
New cards
MySQL updatable view restrictions
Cannot use GROUP BY, HAVING, aggregate functions, DISTINCT, UNION/INTERSECT/MINUS, subqueries in SELECT or FROM, or all types of JOINs; the base table must be key-preserved.
8
New cards
Key-preserved table
A base table whose primary key values remain unique in the view (required for an updatable view).
9
New cards
Trigger
Procedural SQL code automatically invoked by the DBMS when a data manipulation event (INSERT, UPDATE, DELETE) occurs on a table.
10
New cards
When can a trigger fire
BEFORE or AFTER an INSERT, UPDATE, or DELETE on a row.
11
New cards
Trigger syntax (MySQL)
CREATE TRIGGER trigger_name [BEFORE/AFTER] [INSERT/UPDATE/DELETE] ON table_name FOR EACH ROW BEGIN SQL_statements; END;
12
New cards
Four common uses of triggers (Oracle's recommendation)
Auditing, automatic generation of derived columns, enforcement of business or security constraints, creation of replica tables for backup.
13
New cards
Trigger vs stored procedure (key difference)
A trigger fires automatically on a data event; a stored procedure must be explicitly called.
14
New cards
Persistent Stored Module (PSM)
A block of standard SQL plus procedural extensions stored and executed at the DBMS server (defined by SQL-99). Used for triggers, stored procedures, and procedural SQL functions.