Commit 39b8c069 authored by Linnea Schmitt's avatar Linnea Schmitt

Upload New File

parent 904861dd
--Die Reihenfolge ist nicht mehr in der Reihenfolge in der ich sie bearbeitet habe, da ursprnglich nicht alles in einer Datei hatte.
-- Tabelle employees erstellen
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)
);
--Tabell regions erstellen
create table regions(
region_id integer,
region_headquarter_city character varying(40) not null
);
--Tabelle employees_regions erstellen
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 erstellen
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 erstellen
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 = 52835397253836;
--Index erstellen
create index idx_employees_last_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