-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
62 lines (58 loc) · 1.32 KB
/
Copy pathschema.sql
File metadata and controls
62 lines (58 loc) · 1.32 KB
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
57
58
59
60
61
62
-- * Letting the user know to drop database if not created **
DROP DATABASE IF EXISTS employeetrackerdb;
-- Create the database task_saver_db and specified it for use.
CREATE DATABASE `employeetrackerdb`;
-- Use this table to start project.
USE `employeetrackerdb`;
-- Create the table needed.
-- Used PRIMARY KEY and FOREIGN KEY to make all three inner join
-- * **department**:
-- * **roles**:
-- * **employee**:
-- * **id** - INT PRIMARY KEY
-- * VARCHAR(30) awaits the command
-- * DECIMAL(P,D):
-- * 1. P : precision that represents the number of significant digits
-- * 2. D : scale that that represents the number of digits after the decimal point.
USE employeetracker_db;
-- * Extention Keeps formating code...
CREATE TABLE department
(
id int not null
AUTO_INCREMENT,
name varchar
(30),
PRIMARY Key
(id)
);
CREATE TABLE role
(
id int not null
AUTO_INCREMENT,
title varchar
(30),
salary DECIMAL
(10,2),
department_id int,
FOREIGN KEY
(department_id) REFERENCES department
(id),
PRIMARY KEY
(id)
);
CREATE TABLE employee
(
id int not null
AUTO_INCREMENT,
first_name varchar
(30),
last_name varchar
(30),
role_id int,
manager_id int null,
FOREIGN KEY
(role_id) REFERENCES role
(id),
PRIMARY Key
(id)
);