text: CREATE TABLE "departments" (
      "dept_no" VARCHAR(10)   NOT NULL,
      "dept_name" VARCHAR(30)   NOT NULL,
      CONSTRAINT "pk_departments" PRIMARY KEY (
          "dept_no"
       )
  );
  
  CREATE TABLE "dept_emp" (
      "emp_no" INT   NOT NULL,
      "dept_no" VARCHAR(10)   NOT NULL,
      CONSTRAINT "pk_dept_emp" PRIMARY KEY (
          "emp_no","dept_no"
       )
  );
  
  CREATE TABLE "dept_manager" (
      "dept_no" VARCHAR(10)   NOT NULL,
      "emp_no" INT   NOT NULL,
      CONSTRAINT "pk_dept_manager" PRIMARY KEY (
          "dept_no","emp_no"
       )
  );
  
  CREATE TABLE "employees" (
      "emp_no" INT   NOT NULL,
      "emp_title_id" VARCHAR(10)   NOT NULL,
      "birth_date" VARCHAR(10)   NOT NULL,
      "first_name" VARCHAR(30)   NOT NULL,
      "last_name" VARCHAR(30)   NOT NULL,
      "sex" VARCHAR(1)   NOT NULL,
      "hire_date" VARCHAR(10)   NOT NULL,
      CONSTRAINT "pk_employees" PRIMARY KEY (
          "emp_no"
       )
  );
  
  CREATE TABLE "salaries" (
      "emp_no" INT   NOT NULL,
      "salary" INT   NOT NULL
  );
  
  CREATE TABLE "titles" (
      "emp_title_id" VARCHAR(10)   NOT NULL,
      "title" VARCHAR(30)   NOT NULL,
      CONSTRAINT "pk_titles" PRIMARY KEY (
          "emp_title_id"
       )
  );
  
  ALTER TABLE "dept_emp" ADD CONSTRAINT "fk_dept_emp_emp_no" FOREIGN KEY("emp_no")
  REFERENCES "employees" ("emp_no");
  
  ALTER TABLE "dept_emp" ADD CONSTRAINT "fk_dept_emp_dept_no" FOREIGN KEY("dept_no")
  REFERENCES "departments" ("dept_no");
  
  ALTER TABLE "dept_manager" ADD CONSTRAINT "fk_dept_manager_dept_no" FOREIGN KEY("dept_no")
  REFERENCES "departments" ("dept_no");
  
  ALTER TABLE "dept_manager" ADD CONSTRAINT "fk_dept_manager_emp_no" FOREIGN KEY("emp_no")
  REFERENCES "employees" ("emp_no");
  
  ALTER TABLE "employees" ADD CONSTRAINT "fk_employees_emp_title_id" FOREIGN KEY("emp_title_id")
  REFERENCES "titles" ("emp_title_id");
  
  ALTER TABLE "salaries" ADD CONSTRAINT "fk_salaries_emp_no" FOREIGN KEY("emp_no")
  REFERENCES "employees" ("emp_no");
  
  SELECT * FROM employees
  
  SELECT employees.emp_no, employees.first_name, employees.last_name, employees.sex, salaries.salary
  FROM employees
  INNER JOIN salaries
  ON employees.emp_no=salaries.emp_no
  ;
  
  SELECT first_name, last_name, hire_date
  FROM employees
  WHERE hire_date like '%1986'
  ;
  
  SELECT dept_manager.dept_no, departments.dept_name, dept_manager.emp_no, employees.last_name, employees.first_name
  FROM dept_manager
  INNER JOIN departments
  ON dept_manager.dept_no=departments.dept_no
  INNER JOIN employees
  ON dept_manager.emp_no=employees.emp_no
  ;
  
  SELECT employees.emp_no, employees.last_name, employees.first_name, departments.dept_name
  FROM employees
  INNER JOIN dept_emp
  ON employees.emp_no=dept_emp.emp_no
  INNER JOIN departments 
  ON dept_emp.dept_no=departments.dept_no
  ;
  
  SELECT first_name, last_name, sex
  FROM employees
  WHERE first_name='Hercules'
  AND last_name like 'B%'
  ;
  
  SELECT employees.emp_no, employees.last_name, employees.first_name, departments.dept_name
  FROM employees
  INNER JOIN dept_emp
  ON employees.emp_no=dept_emp.emp_no
  INNER JOIN departments 
  ON dept_emp.dept_no=departments.dept_no
  WHERE departments.dept_name='Sales'
  ;
  
  SELECT employees.emp_no, employees.last_name, employees.first_name, departments.dept_name
  FROM employees
  INNER JOIN dept_emp
  ON employees.emp_no=dept_emp.emp_no
  INNER JOIN departments 
  ON dept_emp.dept_no=departments.dept_no
  WHERE departments.dept_name='Sales' 
  OR departments.dept_name='Development'
  ;
  
  SELECT COUNT(last_name) as last_name_frequency, last_name
  FROM employees
  GROUP BY last_name
  ORDER BY last_name_frequency DESC
  ;