-
Notifications
You must be signed in to change notification settings - Fork 0
/
tables_creation.sql
56 lines (41 loc) · 941 Bytes
/
tables_creation.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
CREATE TABLE departments (
id VARCHAR PRIMARY KEY,
name VARCHAR(40)
);
CREATE TABLE employees (
id VARCHAR PRIMARY KEY,
birthdate DATE,
firstname VARCHAR(40),
lastname VARCHAR(40),
gender VARCHAR(1),
startdate date
);
CREATE TABLE departments_employees (
employee_id VARCHAR(20),
department_id VARCHAR(20),
FOREIGN KEY (employee_id) REFERENCES employees (id),
FOREIGN KEY (department_id) REFERENCES departments(id),
startdate DATE,
enddate DATE
);
CREATE TABLE departments_managers (
id VARCHAR(20) PRIMARY KEY,
department_id VARCHAR(20),
FOREIGN KEY (department_id) REFERENCES departments(id),
startdate DATE,
enddate VARCHAR
);
CREATE TABLE salaries (
employee_id VARCHAR(20),
FOREIGN KEY (employee_id) REFERENCES employees(id),
salary INT,
startdate DATE,
enddate DATE
);
CREATE TABLE titles (
employee_id VARCHAR(20),
FOREIGN KEY (employee_id) REFERENCES employees(id),
title VARCHAR(30),
startdate DATE,
enddate DATE
);