Commit 055706c5 authored by Thomas Klauer's avatar Thomas Klauer
Browse files

Merge branch 'undefined' into 'master'

Upload New File

See merge request thomasklauer/datenbanken-ss20!20
parents 610846f6 6181399b
CREATE TABLE employees (
employee_id smallint NOT NULL,
last_name character varying(20) NOT NULL,
first_name character varying(30) NOT NULL,
title character varying(30),
title_of_courtesy character varying(25),
birth_date date,
hire_date date,
address character varying(60),
city character varying(15),
region character varying(15),
postal_code character varying(10),
country character varying(15),
home_phone character varying(24),
extension character varying(4),
photo bytea,
notes text,
reports_to smallint,
photo_path character varying(255)
ALTER TABLE employees ADD CONSTRAINT employees_pk PRIMARY KEY (employee_id);
ALTER TABLE employees ADD CONSTRAINT employees_fk FOREIGN KEY (reports_to) REFERENCES employees(employee_id);
-- die Daten aus der Tabelle employees.csv wurden mittels RMT auf Tabelle --> Daten importieren eingelesen
CREATE TABLE regions (
region_id integer NOT null,
region_headquarter_city character varying(40) NOT NULL
ALTER TABLE regions ADD CONSTRAINT regions_pk PRIMARY KEY (regions_id);
CREATE TABLE employees_regions (
employee_id smallint NOT null,
region_id integer NOT NULL
ALTER TABLE employees_regions ADD CONSTRAINT employees_regions_pk PRIMARY KEY (employee_id, region_id);
ALTER TABLE employees_regions ADD CONSTRAINT employees_regions_fk FOREIGN KEY (employee_id) REFERENCES employees(employee_id);
ALTER TABLE employees_regions ADD CONSTRAINT employees_regions_fk_1 FOREIGN KEY (region_id) REFERENCES regions(region_id);
ALTER TABLE orders ADD CONSTRAINT orders_fk FOREIGN KEY (employee_id) REFERENCES employees(employee_id);
insert into regions values (1,'Mainz'),(2,'Madrid'),(3,'Miami'),(4,'Rio de Janeiro');
insert into employees_regions values (1,3), (2,3), (3,2), (4,2), (5,1), (6,1), (7,4), (8,3), (9,4);
alter table employees add column mobilephonenumber character varying(25);
update employees set mobilephonenumber='0123456789';
create index idx_name on employees(last_name);
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment