Question: consider the database with around 1 0 0 0 0 records: CREATE TABLE employees ( emp _ no INT NOT NULL, birth _ date DATE

consider the database with around 10000 records:
CREATE TABLE employees (
emp_no INT NOT NULL,
birth_date DATE NOT NULL,
first_name VARCHAR(14) NOT NULL,
last_name VARCHAR(16) NOT NULL,
gender ENUM ('M','F') NOT NULL,
hire_date DATE NOT NULL,
PRIMARY KEY (emp_no)
);
Answer those questions:
1) The company has frequent look-ups of its employees by ID, i.e. whenever a person's job or salary is reviewed on a screen. The query is:
SELECT * FROM employees WHERE emp_no =212900;
Would you consider adding an index to the employees table to make this query faster? Discuss and give reasons.
2) To determine the eligibility of employees for certain bonuses, the employees often have to be listed by age (or rather, birth year).
SELECT emp_no FROM employees WHERE YEAR(birth_date)<=1960;
What could potentially be indexed in this case? Add the index and investigate whether it is used when you run this query. What do you conclude?
3) Sometimes the company has to calculate leave entitlements, and for this it is helpful to list employees by hire date:
SELECT emp_no, first_name, last_name FROM employees ORDER BY hire_date;
Add an index where you think it would best help speed up this query and see if it is used.
4) Sometimes the company wants to determine if there is gender bias in appointments to higher positions. For this purpose, male and female employees have to be fetched separately:
SELECT emp_no, first_name, last_name FROM employees WHERE gender ='F';
Add an index where you think it would best help speed up this query and see if it is used.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!