Write a postgre SQL statement to create a table employees, including employee_id, first_name, last_name, email, phone_number hire_date, job_id, salary, commission, manager_id and department_id and make sure that, the employee_id column did not contain any duplicate values at the time of insertion and the foreign key columns combined by department_id and manager_id columns contain only those unique combination values, which combinations exist in the departments table.
Assume the structure of departments table below.
Column | Type | Modifiers
-----------------+-----------------------+--------------------------------
department_id | numeric(4,0) | not null
department_name | character varying(30) | not null
manager_id | numeric(6,0) | not null default NULL::numeric
location_id | numeric(4,0) | default NULL::numeric
Indexes:
"departments_pkey" PRIMARY KEY, btree (department_id, manager_id)
Output:
Here is the command to see the structure of the created table :
postgres=# \d employees Table "public.employees" Column | Type | Modifiers ----------------+-----------------------+--------------------------------- employee_id | numeric(6,0) | not null first_name | character varying(20) | default NULL::character varying last_name | character varying(25) | not null email | character varying(25) | not null phone_number | character varying(20) | default NULL::character varying hire_date | date | not null job_id | character varying(10) | not null salary | numeric(8,2) | default NULL::numeric commission_pct | numeric(2,2) | default NULL::numeric manager_id | numeric(6,0) | default NULL::numeric department_id | numeric(4,0) | default NULL::numeric Indexes: "employees_pkey" PRIMARY KEY, btree (employee_id) Foreign-key constraints: "employees_department_id_fkey" FOREIGN KEY (department_id, manager_id) REFERENCES departments(department_id, manager_id)