Q. Write a trigger that checks the length of a contract when a new contract is inserted into longtermcontract table. If this is the first contract between the pharmacy and pharmaceutical company, the length of the contract should not be more than 12 months. If the contract is more than 12 months, the trigger should alter the end date and reduce it to 12 months after the start date. * You have to use BEFORE INSERT ON * THE INSERT STATEMENT IN THE END OF THE GIVEN CODE MUST WORK. GIVEN CODE:-- Do not change the name of the trigger delimiter // create trigger first_contracts_length_limitation -- do not modify or delete the following lines. Do not write anything after this line. insert into longtermcontract values('parapharmaceutical', '24 South St., Fabreville, QC H7P-E2H', '2020-02-01', '2021-04-01', '***');

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
icon
Concept explainers
Question

Q. Write a trigger that checks the length of a contract when a new contract is inserted into longtermcontract table. If this is the first contract between the pharmacy and pharmaceutical company, the length of the contract should not be more than 12 months. If the contract is more than 12 months, the trigger should alter the end date and reduce it to 12 months after the start date.

* You have to use BEFORE INSERT ON
* THE INSERT STATEMENT IN THE END OF THE GIVEN CODE MUST WORK.

GIVEN CODE:-- Do not change the name of the trigger
delimiter //
create trigger first_contracts_length_limitation

-- do not modify or delete the following lines. Do not write anything after this line.
insert into longtermcontract values('parapharmaceutical', '24 South St., Fabreville, QC H7P-E2H', '2020-02-01', '2021-04-01', '***');

SCRIPT:

I person
SSN INT (11)
| telephone
num ber VARCHAR (50)
Person_SSN INT (11)
Oname VARCHAR(50)
O birthdate DATE
Ostreet_name V ARCHAR(50)
Indexes
Ohouse_number VARCHAR(20)
+
Medical Database
O postal_code VARCHAR(50)
By Dr. Van Woensel (HINF 6220)
+ aity VARCHAR(S0)
O country VAROHAR(50)
O age INT(11)
Indexes
O patient
O physician ▼
SSN INT(11)
Indexes
SSN INT (11)
O Fam Phys_SSN INT(11)
Oemail_address VARCHAR(50)
Indexes
O longtermcontract
PhC_Name VARCHAR(50)
Pha Address VARCHAR(50)
K i start DATE
|prescription
| sellsmedicine
Pha_Address VARCHAR(50)
Med Name VARCHAR( 50)
price INT (11)
O pharmacy
P time DATETIME
P
P
address VARCHAR(50)
Phys_SSN INT(11)
O telephone_number VARCHAR(50)
Pat_SSN INT(11)
Indexes
O Phi_SSN INT (11)
)
Pend DATE
Indexes
Indexes
O text VARCHAR( 50)
Indexes
| prescribedfor
Pres_Time DATETIME
Phys_SSN INT(11)
Pat SSN INT(11)
Med_Name VARCHAR(50)
| includesmedicine
PhC Name VARCHAR(50)
Pha_Address VARCHAR(50)
LongtermContract_Start DATE
O v
D v
O medicine
P name VARCHAR(50)
K
LongtermContract End DATE
Med_Name VARCHAR( 50)
Indexes
O form ula VARCHAR(50)
Indexes
Odosage FLOAT
Indexes
O manufacturesmedicine
O pharmaceuticalcompany
PhC Name VARCHAR(S0)
name VARCHAR(50)
Med Name VARCHAR( 50)
O address VARCHAR(50)
Indexes
Indexes
|contact
type VARCHAR(50)
O telephone VARCHAR(50)
PhC_Name VARCHAR(50)
Indexes
Transcribed Image Text:I person SSN INT (11) | telephone num ber VARCHAR (50) Person_SSN INT (11) Oname VARCHAR(50) O birthdate DATE Ostreet_name V ARCHAR(50) Indexes Ohouse_number VARCHAR(20) + Medical Database O postal_code VARCHAR(50) By Dr. Van Woensel (HINF 6220) + aity VARCHAR(S0) O country VAROHAR(50) O age INT(11) Indexes O patient O physician ▼ SSN INT(11) Indexes SSN INT (11) O Fam Phys_SSN INT(11) Oemail_address VARCHAR(50) Indexes O longtermcontract PhC_Name VARCHAR(50) Pha Address VARCHAR(50) K i start DATE |prescription | sellsmedicine Pha_Address VARCHAR(50) Med Name VARCHAR( 50) price INT (11) O pharmacy P time DATETIME P P address VARCHAR(50) Phys_SSN INT(11) O telephone_number VARCHAR(50) Pat_SSN INT(11) Indexes O Phi_SSN INT (11) ) Pend DATE Indexes Indexes O text VARCHAR( 50) Indexes | prescribedfor Pres_Time DATETIME Phys_SSN INT(11) Pat SSN INT(11) Med_Name VARCHAR(50) | includesmedicine PhC Name VARCHAR(50) Pha_Address VARCHAR(50) LongtermContract_Start DATE O v D v O medicine P name VARCHAR(50) K LongtermContract End DATE Med_Name VARCHAR( 50) Indexes O form ula VARCHAR(50) Indexes Odosage FLOAT Indexes O manufacturesmedicine O pharmaceuticalcompany PhC Name VARCHAR(S0) name VARCHAR(50) Med Name VARCHAR( 50) O address VARCHAR(50) Indexes Indexes |contact type VARCHAR(50) O telephone VARCHAR(50) PhC_Name VARCHAR(50) Indexes
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Control Structure
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
  • SEE MORE 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