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. There are some employees that do not belong to any department (or we do not know in which department they work). For each such employee, list his/her full name.
  2. List the name of each employee who once had the title of "Public Accountant". There shouldn't be duplicates in the result.
  3. List the name of each employee who once had a title that's not "Public Accountant". There shouldn't be duplicates in the result.
  4. List the name of each employee who NEVER had the title of "Public Accountant".
  5. List the unique country id and country name of each country in which at least one department locates.
  6. List the id and name of each department in which no employee works.