Commit 0ee15d82 authored by Pauline Radu's avatar Pauline Radu
Browse files

Upload new File

parent bb3b823b
-- Seperate Datei damit nicht jedes Mal alles durchlaufen muss
-- Fehlende Tabellen einfgen und M-zu-N-Beziehungen auflsen
-- Tabelle employees
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)
);
-- Tabelle regions
create table regions(
region_id integer,
region_headquarter_city character varying(40) not null
);
-- Tabelle employees_regions
create table employees_regions(
employee_id smallint,
region_id integer
);
-- Werte in Tabelle regions einfgen
insert into regions (region_id, region_headquarter_city) values
(1,'Mainz'),
(2,'Madrid'),
(3,'Miami'),
(4,'Rio de Janeiro');
-- Primrschlssel hinzufgen
alter table employees add constraint pk_employees primary key (employee_id);
alter table employees_regions add constraint pk_employee_regions primary key (employee_id, region_id);
-- Fremdschlssel hinzufgen
alter table employees add foreign key (reports_to) references employees(employee_id);
alter table orders add foreign key (employee_id) references employees(employee_id);
alter table employees_regions add foreign key (employee_id) references employees(employee_id);
alter table employees_regions add foreign key (region_id) references regions(region_id);
-- Spalte Handynummer zur Tabelle employees hinzufgen
alter table only employees add column MobilePhoneNumber character varying(25);
-- Spalte Handynummer ausfllen
update employees set mobilephonenumber = 4916700700769;
-- Index erstellen fr employees fr den Nachnamen
create index idx_employees_last_name on employees(last_name);
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