Commit 8a93896f authored by Thomas Klauer's avatar Thomas Klauer
Browse files

Merge branch 'undefined' into 'master'

mihm-elisabeth

See merge request thomasklauer/datenbanken-ss20!4
parents c42ea683 39d5d52f
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)
);
CREATE TABLE regions (
region_id integer NOT null,
region_headquarter_city character varying(40) NOT NULL
);
CREATE TABLE employees_regions (
employee_id smallint NOT null,
region_id integer NOT NULL
);
insert into regions (region_id, region_headquarter_city) values (1, 'Mainz'), (2, 'Madrid'), (3, 'Miami'), (4, 'Rio de Janeiro');
Tabellen employees rechtklick Daten importieren CSV Datei auswählen
ALTER TABLE employees ADD CONSTRAINT employees_pk PRIMARY KEY (employee_id);
ALTER TABLE regions ADD CONSTRAINT regions_pk PRIMARY KEY (region_id);
ALTER TABLE employees_regions ADD CONSTRAINT employees_regions_pk PRIMARY KEY (employee_id,region_id);
ALTER TABLE orders ADD CONSTRAINT orders_fk FOREIGN KEY (employee_id) REFERENCES employees(employee_id);
ALTER TABLE employees ADD CONSTRAINT employees_fk FOREIGN KEY (reports_to) REFERENCES employees(employee_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 employees add column PhoneNumber character varying(24);
update empolyees 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