Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.Consider the following relational scheme. An employee can only work in one department at a time; they can work in another department after they have

1.Consider the following relational scheme. An employee can only work in one department at a time; they can work in another department after they have ended their contract in the current department. A department has only one manager, which is indicated by the Eid as managerid.

Employee(eid: integer, ename: string, age: integer, grade: integer, salary: real)

EmployeeArchives(eid: integer, ename: string, age: integer, grade: integer, salary: real)

Works(eid: integer, did: integer, start_date: date, end_date: date)

Department(did: integer, budget: real, managerid: integer)

Using the available information, use MySQL DDL to create a database from the relational schema above. Make sure to include integrity constraints such as domain, primary key, foreign key and mention your assumptions if needed.

2. Using the same schema from No. 1, write MySQL integrity constraints using CHECK constraints or MySQL Triggers to ensure each of the following requirements, considered independently Make sure to include the test query and its explanation for each constraint using MySQL DML/DDL.

a. Employees must get a minimum salary based on their grade: minimum salary for grade 1 is Rp1.000.000, for grade 2 is Rp2.000.000, and so on, until grade 10, which is Rp10.000.000. Also, note that the value of an employees grade is between 1 and 10.

b. Every employee is given a raise once every year based on their work duration (which is counted from the start date until now). If they have worked for >10 years, the raise is 20%; If they have worked for >5 years, the raise is 15%; If they have worked for >=1 years, the raise is 10%; If they have worked for <1 year, the raise is 5%.

c. A manager's salary must be more than an employees salary within the same department.

d.Whenever an employee is given a raise, the department's budget must be increased to be 10% greater than the sum of salaries of all employees in the department.

e.Whenever an employee is fired or resigned, their data should be deleted from the Employee relation and inserted in a relation named EmployeeArchives.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

From Herds To Insights Harnessing Data Analytics For Sustainable Livestock Farming

Authors: Prof Suresh Neethirajan

1st Edition

B0CFD6K6KK, 979-8857075487

More Books

Students also viewed these Databases questions

Question

assess the infl uence of national culture on the workplace

Answered: 1 week ago