Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 records:
CREATE TABLE employees
empno INT NOT NULL,
birthdate DATE NOT NULL,
firstname VARCHAR NOT NULL,
lastname VARCHAR NOT NULL,
gender ENUM MF NOT NULL,
hiredate DATE NOT NULL,
PRIMARY KEY empno
;
Answer those questions:
The company has frequent lookups of its employees by ID ie whenever a person's job or salary is reviewed on a screen. The query is:
SELECT FROM employees WHERE empno ;
Would you consider adding an index to the employees table to make this query faster? Discuss and give reasons.
To determine the eligibility of employees for certain bonuses, the employees often have to be listed by age or rather, birth year
SELECT empno FROM employees WHERE YEARbirthdate;
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?
Sometimes the company has to calculate leave entitlements, and for this it is helpful to list employees by hire date:
SELECT empno firstname, lastname FROM employees ORDER BY hiredate;
Add an index where you think it would best help speed up this query and see if it is used.
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 empno firstname, lastname 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started