Lab schema (HR schema) is listed as below (primary keys are underlined):

Regions(region_id, region_name);
Countries(country_id, country_name, region_id);
Locations(location_id, street_address, postal_code, city, state_province, country_id);
Departments(department_id, department_name, manager_id, location_id);
Jobs(job_id, job_title, min_salary, max_salary);
Employees(employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, manager_id, department_id);
Job_History(employee_id, start_date, end_date, job_id, department_id);

Learning Objectives:

Write equivalent SQL, Relational Algebra and Datalog query for each of the following questions.

  1. List the first name, last name and hire date of each employee whose phone number has the area code 515;
  2. For each employee, list his/her name and the name of the department he/she works in;
  3. List the first and last name of each employee who works in the department named "Sales" and earns more than $5000;
  4. List the first and last name of each employee who earns the same as or more than the max salary allowed by his/her job title;
  5. For each employee, list his/her name and the name of the employee he/she directly reports to.