
DROP SCHEMA IF EXISTS emp CASCADE;

BEGIN;

CREATE SCHEMA emp;

CREATE TABLE emp.employee_orig ( -- Original table before data loss
    name text,
    position text,
    employed date,
    salary int
);

INSERT INTO emp.employee_orig
SELECT a, b, c::date, d::int FROM (VALUES
('Ole Nilsen', 'lecturer', '2001-03-04', 513190),
('Kari Borgen', 'lecturer', '2010-11-08', 545230),
('Ye Shin', 'lecturer', '2014-10-18', 511400),
('Martin Schwartz', 'lecturer', '2007-11-01', 562900),
('Ove Bole', 'researcher', '2014-02-11', 517480),
('Vera Louise', 'researcher', '2006-09-10', 529100),
('Ida Persson', 'researcher', '2016-12-10', 520800),
('Mary Smith', 'researcher', '2020-01-18', 501990),
('Karla Loe', 'researcher', '2020-01-18', 501990),
('Hannah Stern', 'professor', '2019-05-17', 670500),
('Bo Belle', 'professor', '2011-08-18', 701930),
('Karl Hansen', 'professor', '2016-09-10', 651735),
('Legor Ivani', 'professor', '2021-02-18', 632950),
('Guri Quin', 'professor', '2010-10-01', 699070)) t(a, b, c, d)
ORDER BY random();

CREATE TABLE emp.employee ( -- Table after data loss
    name text,
    position text,
    employed date,
    salary int
);

INSERT INTO emp.employee
SELECT a, b, c::date, d::int FROM (VALUES
('Kari Borgen', 'lecturer', '2010-11-08', 545230),
('Martin Schwartz', 'lecturer', '2007-11-01', 562900),
('Vera Louise', 'researcher', '2006-09-10', 529100),
('Mary Smith', 'researcher', '2020-01-18', 501990),
('Hannah Stern', 'professor', '2019-05-17', 670500),
('Karl Hansen', 'professor', '2016-09-10', 651735),
('Guri Quin', 'professor', '2010-10-01', 699070)) t(a, b, c, d)
ORDER BY random();

CREATE TABLE emp.employee_form ( -- Table to contain result from form
    name text,
    position text,
    employed text,
    salary text
);

END;
