text: ﻿-- Exported from QuickDBD: https://www.quickdatabasediagrams.com/
  -- Link to schema: https://app.quickdatabasediagrams.com/#/d/0n4sq4
  -- NOTE! If you have used non-SQL datatypes in your design, you will have to change these here.
  
  
  CREATE TABLE "employee" (
      "emp_no" int   NOT NULL,
      "emp_title" varchar(30)   NOT NULL,
      "birth_date" date   NOT NULL,
      "first_name" varchar(20)   NOT NULL,
      "last_name" varachar(40)   NOT NULL,
      "hire_date" date   NOT NULL,
      CONSTRAINT "pk_employee" PRIMARY KEY (
          "emp_no"
       )
  );
  
  CREATE TABLE "dept_emp" (
      "emp_no" int   NOT NULL,
      "dept_no" varchar   NOT NULL
  );
  
  CREATE TABLE "department_managers" (
      "dept_no" varchar   NOT NULL,
      "emp_no" int   NOT NULL
  );
  
  CREATE TABLE "salaries" (
      "emp_no" int   NOT NULL,
      "salary" float   NOT NULL
  );
  
  CREATE TABLE "titles" (
      "title_id" varchar(30)   NOT NULL,
      "title" varchar   NOT NULL,
      CONSTRAINT "pk_titles" PRIMARY KEY (
          "title_id"
       )
  );
  
  CREATE TABLE "departments" (
      "dept_no" varchar   NOT NULL,
      "dept_name" varchar   NOT NULL,
      CONSTRAINT "pk_departments" PRIMARY KEY (
          "dept_no"
       )
  );
  
  ALTER TABLE "employee" ADD CONSTRAINT "fk_employee_emp_title" FOREIGN KEY("emp_title")
  REFERENCES "titles" ("title_id");
  
  ALTER TABLE "dept_emp" ADD CONSTRAINT "fk_dept_emp_emp_no" FOREIGN KEY("emp_no")
  REFERENCES "employee" ("emp_no");
  
  ALTER TABLE "dept_emp" ADD CONSTRAINT "fk_dept_emp_dept_no" FOREIGN KEY("dept_no")
  REFERENCES "departments" ("dept_no");
  
  ALTER TABLE "department_managers" ADD CONSTRAINT "fk_department_managers_dept_no" FOREIGN KEY("dept_no")
  REFERENCES "departments" ("dept_no");
  
  ALTER TABLE "department_managers" ADD CONSTRAINT "fk_department_managers_emp_no" FOREIGN KEY("emp_no")
  REFERENCES "employee" ("emp_no");
  
  ALTER TABLE "salaries" ADD CONSTRAINT "fk_salaries_emp_no" FOREIGN KEY("emp_no")
  REFERENCES "employee" ("emp_no");
  
  