-- Table Trips -- DROP TABLE Trips CREATE TABLE Trips id integer NOT N

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-- Table: "Trips"
-- DROP TABLE "Trips";
CREATE TABLE "Trips"
(
id integer NOT NULL DEFAULT nextval('trip_id_seq'::regclass),
date date,
rating double precision,
student_id integer NOT NULL,
CONSTRAINT "Trips_pkey" PRIMARY KEY (id),
CONSTRAINT "Trips_fk" FOREIGN KEY (student_id)
REFERENCES "Students" (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE "Trips"
OWNER TO postgres;
ALTER TABLE "Trips" ALTER COLUMN id SET STATISTICS 0;
-- Trigger: Trips_on_create on "Trips"
-- DROP TRIGGER "Trips_on_create" ON "Trips";
CREATE TRIGGER "Trips_on_create"
AFTER INSERT OR UPDATE
ON "Trips"
FOR EACH ROW
EXECUTE PROCEDURE update_student_gpa_on_create_update_trip();
-- Trigger: Trips_on_delete on "Trips"
-- DROP TRIGGER "Trips_on_delete" ON "Trips";
CREATE TRIGGER "Trips_on_delete"
AFTER DELETE
ON "Trips"
FOR EACH ROW
EXECUTE PROCEDURE update_student_gpa_on_delete_trip();