******Please help with 6-9***** Create the database for following relational sch
ID: 3855122 • Letter: #
Question
******Please help with 6-9*****
Create the database for following relational schema with Employee, Department, and Works tables: Employee(eid: integer, ename: string, age: integer, salary: real) Works(eid: integer, did: integer, hours: integer) Department(did: integer, dname: string, budget: real, managerid: intege Define a table constraint on Department that will ensure that managerid is always positive and less than 1000. Insert the following records in the database: Get the sorted list of name and budget of each department in which employee Jones works. Get the name and id of youngest employee in Research department. Create a view that shows the eids and managerids in Sales department. Add a column called numHours to the Employee table. Use the UPDATE command to insert values into this new column to correspond to the current information in the Works table. Write a trigger that will increment the new field numHours in the Employee table automatically whenever a record is inserted in the Works table. Write a trigger that will decrement the new field numHours in the Employee table.Explanation / Answer
6.
CREATE VIEW abc
AS SELECT works.eids,department.managerid
FROM Works,Department
WHERE Department.dname='Sales';
7.
ALTER TABLE Employee
ADD numHours int;
UPDATE Employee
SET numHours=(SELECT hours FROM Works)
WHERE employee.eid=Works.hours;
8.
CREATE TRIGGER incnumHours
AFTER INSERT OF ON Works
FOR EACH ROW
BEGIN
Employee.numHours=Employee.numHours+1
END;
9.
CREATE TRIGGER incnumHours ]
FOR EACH ROW
BEGIN
Employee.numHours=Employee.numHours+1
END;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.