Answered step by step
Verified Expert Solution
Link Copied!

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 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

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

Step: 3

blur-text-image

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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

I receive useful feedback about my performance.

Answered: 1 week ago

Question

I am encouraged to offer opinions/suggestions.

Answered: 1 week ago