Commit 4de445ab authored by Thomas Klauer's avatar Thomas Klauer
Browse files

Merge branch 'undefined' into 'master'

Kosiahn-Marie-Ueb3.2-3.3

See merge request thomasklauer/datenbanken-ss20!11
parents 8a8c9c9d 16509274
create table employees (
employee_id smallint not null,
last_name varchar(20) not null,
first_name varchar(30) not null,
title varchar(30),
title_of_courtesy varchar(25),
birth_date date,
hire_date date,
address varchar(60),
city varchar(15),
region varchar(15),
postal_code varchar(10),
country varchar(15),
home_phone varchar(24),
extension varchar(4),
photo bytea,
notes text,
reports_to smallint,
photo_path varchar(255),
constraint pk_employees primary key (employee_id)
);
create table regions (
region_id integer not null,
region_headquarter_city varchar(40) not null,
constraint pk_regions primary key (region_id)
);
create table employee_regions (
employee_id integer not null references employees (employee_id),
region_id integer not null references regions (region_id),
constraint pk_employee_regions primary key (employee_id, region_id)
);
insert into
regions
values
('1','Mainz'),
('2','Madrid'),
('3','Miami'),
('4','Rio de Janeiro');
/*2.2 Import der csv Datei ueber Rechtsklick auf die Tabelle emnployees im Datenbanknavigator,
* "Datei importieren, .csv auswaehlen, zur Datei navigieren und Import starten*/
alter table orders
add foreign key (employee_id) references employees(employee_id);
alter table employees
add foreign key (reports_to) references employees(employee_id);
insert into
employee_regions
values
((SELECT employee_id from employees where employee_id=1) ,
(SELECT region_id from regions where region_id=3)),
((SELECT employee_id from employees where employee_id=2) ,
(SELECT region_id from regions where region_id=3)),
((SELECT employee_id from employees where employee_id=3) ,
(SELECT region_id from regions where region_id=2)),
((SELECT employee_id from employees where employee_id=4) ,
(SELECT region_id from regions where region_id=2)),
((SELECT employee_id from employees where employee_id=5) ,
(SELECT region_id from regions where region_id=1)),
((SELECT employee_id from employees where employee_id=6) ,
(SELECT region_id from regions where region_id=1)),
((SELECT employee_id from employees where employee_id=7) ,
(SELECT region_id from regions where region_id=4)),
((SELECT employee_id from employees where employee_id=8) ,
(SELECT region_id from regions where region_id=3)),
((SELECT employee_id from employees where employee_id=9) ,
(SELECT region_id from regions where region_id=4));
alter table employees
add column MobilePhoneNumber varchar(24);
update employees set MobilePhoneNumber = '0123456789';
/*Hier ohne 'where', da als Dummy bei jedem Mitarbeiter der gleiche Wert eingesetzt wird*/
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