Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. (5 pts) Assume two tables T3 and T4 have been created as follows. Table T4 ke

ID: 3601537 • Letter: 2

Question

2. (5 pts) Assume two tables T3 and T4 have been created as follows. Table T4 keeps track of the number of times (c) that a certain string (s) appears in table T3 create table T3 s varchar2 (100), x nimber, Y number primary key (x, y) create table T4 s varchar2 (100) primary key, c number, 0) For example, T3 contains computer database networking 7 graphics networking1 networking computer Then T4 should contain: computer database networking.3 graphics Write a trigger TriggerProblem2 such that every time a new record is inserted into table 73, table T4 should be updated accordingly. For example, after a row database. 5, 5) is inserted into table T3, table T4 should be changed to: computer database networking 3 graphics

Explanation / Answer

Following trigger will update the table T4 on inserting a record in table T3 as per the given condition.

First using the select query a records are count based on matching insertion, then the count is updated using the update statement in the T4 table.

CREATE TRIGGER update_t4

AFTER UPDATE ON T3

FOR each row

BEGIN

DECLARE updateCount INT;

        SET updateCount = ( SELECT COUNT(*) FROM T3 WHERE s = new.s );

        UPDATE T4 SET c = updateCount WHERE s = new.s;

END;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote