A database administrator wants to know the details of the materials used on site A  (job tag) and site B (job tag) on two days of the week. Given the work on site B was done on the two days and completed and site A is yet to be completed. Create the required query needed to give the administrator the current update on both sites and triggers to handle the  Created_at and updated_at.  please refer below for more information: CREATE TABLE Transaction (        Transaction_no SERIAL,        Product_no INT NOT NULL PRIMARY KEY,        Product_name VARCHAR(250) NOT NULL,        TxAmount_used Float NOT NULL,        Job_tag VARCHAR(250) NOT NULL,        TxStatus Status,        Uses jsonb NOT NULL,        Created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,        Updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,        TxAmount FLOAT,        RefNbr INT); Created_at indicates the date and time when the “transaction” was created. It is automatically added every time a trigger is added, with the current time stamp as the value. Updated_at is similar to created_at, except that it is updated every time a “transaction” is updated (e.g, uses, status change etc ). To enable updated_at to be updated as explained above, a trigger needs to be created on the database. Uses is a json object which logs each individual use of the material. Every time technicians log a material’s use on the sites, the name of the technician, the product no, and the amount used are logged as an object in the form of {“name” : “amount”} Status indicates whether the material is still being used on-site, or whether it has already been used. job_tag is the site name for which the material will be used. The user will be prompted to input the job_tag when checking out a material to go the site. amount_used is the total amount of material used on site. Its initial value is 0, and is incremented every time a technician logs its use on the app. The amount specified by the technician is appended to amount_used’s current value TxAmount represents the initial material taken to the site at the start of the job and is only updated to show what is left after the job is completed. For site A, it shows what was taken to the site as the job is not complete, and for site B the balance of the material is left.  transaction_no is a counter which automatically increases and is automatically added to every row created in the table.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

A database administrator wants to know the details of the materials used on site A  (job tag) and site B (job tag) on two days of the week. Given the work on site B was done on the two days and completed and site A is yet to be completed. Create the required query needed to give the administrator the current update on both sites and triggers to handle the  Created_at and updated_at.  please refer below for more information:

CREATE TABLE Transaction (
       Transaction_no SERIAL,
       Product_no INT NOT NULL PRIMARY KEY,
       Product_name VARCHAR(250) NOT NULL,
       TxAmount_used Float NOT NULL,
       Job_tag VARCHAR(250) NOT NULL,
       TxStatus Status,
       Uses jsonb NOT NULL,
       Created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
       Updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
       TxAmount FLOAT,
       RefNbr INT);

Created_at indicates the date and time when the “transaction” was created. It is automatically added every time a trigger is added, with the current time stamp as the value.

Updated_at is similar to created_at, except that it is updated every time a “transaction” is updated (e.g, uses, status change etc ). To enable updated_at to be updated as explained above, a trigger needs to be created on the database.

Uses is a json object which logs each individual use of the material. Every time technicians log a material’s use on the sites, the name of the technician, the product no, and the amount used are logged as an object in the form of {“name” : “amount”}

Status indicates whether the material is still being used on-site, or whether it has already been used.

job_tag is the site name for which the material will be used. The user will be prompted to input the job_tag when checking out a material to go the site.

amount_used is the total amount of material used on site. Its initial value is 0, and is incremented every time a technician logs its use on the app. The amount specified by the technician is appended to amount_used’s current value

TxAmount represents the initial material taken to the site at the start of the job and is only updated to show what is left after the job is completed. For site A, it shows what was taken to the site as the job is not complete, and for site B the balance of the material is left. 

transaction_no is a counter which automatically increases and is automatically added to every row created in the table. 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Database Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education