-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComp_Data_1_Part2
63 lines (41 loc) · 2.18 KB
/
Comp_Data_1_Part2
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
63
Hello, this is part 2 of our company database. Here we will insert information into our employee table and branch table.
-----Corporate Branch
INSERT INTO employee VALUES(100,'David','Wallace','1967-11-17','M',250000,NULL,NULL);
INSERT INTO branch VALUES(1,'Corporate',100,'2006-02-09');
UPDATE employee
SET branch_id=1
WHERE emp_id=100;
INSERT INTO employee VALUES(101,'Jan','Levinson','1961-05-11','F',110000,100,1);
------Scranton Branch
INSERT INTO employee VALUES(102,'Michael','Scott','1964-03-15','M',75000,100,NULL);
INSERT INTO branch VALUES(2,'Scranton',102,'1992-04-06');
INSERT INTO employee VALUES(103,'Angela','Martin','1971-05-25','F',63000,102,NULL);
INSERT INTO employee VALUES(104,'Kelly','Kapoor','1980-02-05','F',55000,102,NULL);
INSERT INTO employee VALUES(105,'Stanley','Hudson','1958-02-19','M',69000,102,NULL);
UPDATE employee
SET branch_id=2
WHERE emp_id=102 OR emp_id=103 OR emp_id=104 OR emp_id=105;
------Stamford Branch
INSERT INTO employee VALUES(106,'Josh','Portar','1969-09-05','M',78000,100,NULL);
INSERT INTO branch VALUES(3,'Stamford',106,'1998-02-13');
UPDATE employee
SET branch_id=3
WHERE emp_id=106;
INSERT INTO employee VALUES(107,'Andy','Bernadr','1973-07-22','M',65000,106,3);
INSERT INTO employee VALUES(108,'Jim','Halpert','1978-10-01','M',71000,106,3);
#######Now the employee table will look like this.
emp_id first_name last_name birth_date sex salary super_id branch_id
100 David Wallace 1967-11-17 M 250000 NULL 1
101 Jan Levinson 1961-05-11 F 110000 100 1
102 Michael Scott 1964-03-15 M 75000 100 2
103 Angela Martin 1971-05-25 F 63000 102 2
104 Kelly Kapoor 1980-02-05 F 55000 102 2
105 Stanley Hudson 1958-02-19 M 69000 102 2
106 Josh Portar 1969-09-05 M 78000 100 3
107 Andy Bernadr 1973-07-22 M 65000 106 3
108 Jim Halpert 1978-10-01 M 71000 106 3
####### The branch table will look like this.
branch_id branch_name mgr_id mgr_start_date
1 Corporate 100 2006-02-09
2 Scranton 102 1992-04-06
3 Stamford 106 1998-02-13