Lecture 3
Lecture 3
4 4 4 Spring outing
artists created collections
id name artist_id collection_id id title
4 4 4 Spring outing
FOREIGN KEY("artist_id") REFERENCES "artists"("id")
FOREIGN KEY("artist_id") REFERENCES "artists"("id")
ON DELETE …
FOREIGN KEY("artist_id") REFERENCES "artists"("id")
ON DELETE RESTRICT
FOREIGN KEY("artist_id") REFERENCES "artists"("id")
ON DELETE NO ACTION
FOREIGN KEY("artist_id") REFERENCES "artists"("id")
ON DELETE SET NULL
FOREIGN KEY("artist_id") REFERENCES "artists"("id")
ON DELETE SET DEFAULT
FOREIGN KEY("artist_id") REFERENCES "artists"("id")
ON DELETE CASCADE
artists created collections
id name artist_id collection_id id title
4 4 4 Spring outing
artists created collections
id name artist_id collection_id id title
4 Spring outing
Update
artists created collections
id name artist_id collection_id id title
1 Farmers working …
2 Imaginative land…
3 Profusion of …
4 Spring outing
collections transactions
id title id title action
1 Farmers working …
2 Imaginative land…
3 Profusion of …
4 Spring outing
collections transactions
id title id title action
1 Farmers working …
2 Imaginative land…
3 Profusion of …
collections transactions
id title id title action
2 Imaginative land…
3 Profusion of …
collections transactions
id title id title action
2 Imaginative land…
3 Profusion of …
collections transactions
id title id title action
2 Imaginative land…
3 Profusion of …
4 Peonies and …
collections transactions
id title id title action
3 Profusion of …
4 Peonies and …
CREATE TRIGGER name
CREATE TRIGGER name
AFTER
CREATE TRIGGER name
BEFORE
CREATE TRIGGER name
BEFORE INSERT ON table
CREATE TRIGGER name
BEFORE UPDATE OF column ON table
CREATE TRIGGER name
BEFORE DELETE ON table
CREATE TRIGGER name
BEFORE DELETE ON table
FOR EACH ROW
CREATE TRIGGER name
BEFORE DELETE ON table
FOR EACH ROW
BEGIN
CREATE TRIGGER name
BEFORE DELETE ON table
FOR EACH ROW
BEGIN
…;
CREATE TRIGGER name
BEFORE DELETE ON table
FOR EACH ROW
BEGIN
…;
END;
Soft Deletions
collections
id title deleted
1 Farmers working … 0
2 Imaginative land… 0
3 Profusion of … 0
4 Peonies and … 0
collections
id title deleted
1 Farmers working … 0
2 Imaginative land… 0
3 Profusion of … 0
4 Peonies and … 0
collections
id title deleted
1 Farmers working … 1
2 Imaginative land… 0
3 Profusion of … 0
4 Peonies and … 0
Introduction to
Databases with SQL
Writing