-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee_Payroll_Service_MySQL.txt
More file actions
625 lines (540 loc) · 26.2 KB
/
Employee_Payroll_Service_MySQL.txt
File metadata and controls
625 lines (540 loc) · 26.2 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
********** Welcome to the Employee_Payroll_Service**********************
---------------------------------------------------
#UC1 ::: Create, show and use Database
---------------------------------------------------
Microsoft Windows [Version 10.0.22616.100]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Raj Kawale>cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p
Enter password: **************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.28 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#Checking existing Databases
mysql> show databases;
+------------------------+
| Database |
+------------------------+
| bank_management_system |
| employee_info |
| information_schema |
| myinfo |
| mysql |
| performance_schema |
| sakila |
| shop |
| students |
| sys |
| world |
+------------------------+
11 rows in set (0.00 sec)
#Creating new database
mysql> create database Employee_payroll_service;
Query OK, 1 row affected (0.04 sec)
#Checking database if its added
mysql> show databases;
+--------------------------+
| Database |
+--------------------------+
| bank_management_system |
| employee_info |
| employee_payroll_service |
| information_schema |
| myinfo |
| mysql |
| performance_schema |
| sakila |
| shop |
| students |
| sys |
| world |
+--------------------------+
12 rows in set (0.00 sec)
#Selecting database
mysql> use Employee_payroll_service;
Database changed
#Checking existing data/tables into selected database
mysql> show tables;
Empty set (0.01 sec)
mysql> select database Employee_payroll_service;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Employee_payroll_service' at line 1
#Selecting and Using Database to perform the task (Queries)
mysql> select database ();
+--------------------------+
| database () |
+--------------------------+
| employee_payroll_service |
+--------------------------+
1 row in set (0.00 sec)
-------------------------------------------------------
#UC2 ::: To Create table Employee_Payroll
-------------------------------------------------------
#Creating table to add the data
mysql> create table Employee_payroll (id int (10) unsigned auto_increment primary key not null, name varchar (50) not null, salary double not null, start date not null);
Query OK, 0 rows affected, 1 warning (0.06 sec)
#Checking table if its added
mysql> show tables;
+------------------------------------+
| Tables_in_employee_payroll_service |
+------------------------------------+
| employee_payroll |
+------------------------------------+
1 row in set (0.00 sec)
#Selecting table to describing the data
mysql> describe Employee_payroll; #To view all the data from the table
+--------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+----------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(50) | NO | | NULL | |
| salary | double | NO | | NULL | |
| start | date | NO | | NULL | |
+--------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
===========================================================================================================================================
------------------------------------------------------------------------
#UC3 ::: To Enter the data into table Employee_Payroll
------------------------------------------------------------------------
#Inserting data into tables
mysql> insert into Employee_payroll(name, salary, start) values ('Raj', 50000, '2022-05-01'), ('Sam', 55000, '2021-12-01'), ('David', 60000, '2021-06-01'), ('Zayn', 100000, '2020-12-01');
Query OK, 4 rows affected (0.02 sec)
Records: 4 Duplicates: 0 Warnings: 0
===========================================================================================================================================
-------------------------------------------------------
#UC4 ::: To View the data into table Employee_Payroll
-------------------------------------------------------
#Retrieving data from Table
mysql> select *from Employee_payroll;
+----+-------+--------+------------+
| id | name | salary | start |
+----+-------+--------+------------+
| 1 | Raj | 50000 | 2022-05-01 |
| 2 | Sam | 55000 | 2021-12-01 |
| 3 | David | 60000 | 2021-06-01 |
| 4 | Zayn | 100000 | 2020-12-01 |
+----+-------+--------+------------+
4 rows in set (0.00 sec)
#Selecting David from table by denoted salary
mysql> select salary from Employee_payroll WHERE name = 'David';
+--------+
| salary |
+--------+
| 60000 |
+--------+
1 row in set (0.03 sec)
#Deleting data of David from table
mysql> DELETE FROM Employee_payroll WHERE name='David';
Query OK, 1 row affected (0.02 sec)
#Inserting data to the table
mysql> INSERT INTO Employee_payroll (name, salary, start) VALUES ('Bill', 1000000.00, '2018-01-03');
Query OK, 1 row affected (0.01 sec)
#Displaying Data to check new entry
mysql> select *from Employee_payroll;
+----+------+---------+------------+
| id | name | salary | start |
+----+------+---------+------------+
| 1 | Raj | 50000 | 2022-05-01 |
| 2 | Sam | 55000 | 2021-12-01 |
| 4 | Zayn | 100000 | 2020-12-01 |
| 5 | Bill | 1000000 | 2018-01-03 |
+----+------+---------+------------+
4 rows in set (0.00 sec)
===========================================================================================================================================
--------------------------------------------------------
#UC5 ::: Retrieving Salary Data From table
--------------------------------------------------------
#Select employee from date range
mysql> SELECT * FROM Employee_payroll WHERE start BETWEEN CAST('2018-01-01' AS DATE) AND DATE(NOW());
+----+------+---------+------------+
| id | name | salary | start |
+----+------+---------+------------+
| 1 | Raj | 50000 | 2022-05-01 |
| 2 | Sam | 55000 | 2021-12-01 |
| 4 | Zayn | 100000 | 2020-12-01 |
| 5 | Bill | 1000000 | 2018-01-03 |
+----+------+---------+------------+
4 rows in set (0.01 sec)
===========================================================================================================================================
-----------------------------------------------------------------------
#UC6 ::: Adding Columns (Gender) and updating row
----------------------------------------------------------------------
#Adding column Gender to the table
mysql> ALTER TABLE Employee_payroll ADD gender CHAR(1) AFTER name;
Query OK, 0 rows affected (0.10 sec)
Records: 0 Duplicates: 0 Warnings: 0
#Checking Gender column if its add
mysql> select *from Employee_payroll;
+----+------+--------+---------+------------+
| id | name | gender | salary | start |
+----+------+--------+---------+------------+
| 1 | Raj | NULL | 50000 | 2022-05-01 |
| 2 | Sam | NULL | 55000 | 2021-12-01 |
| 4 | Zayn | NULL | 100000 | 2020-12-01 |
| 5 | Bill | NULL | 1000000 | 2018-01-03 |
+----+------+--------+---------+------------+
4 rows in set (0.00 sec)
mysql> UPDATE Employee_payroll set gender = 'M' WHERE name = 'Raj';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE Employee_payroll set gender = 'M' WHERE name = 'Sam';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE Employee_payroll set gender = 'M' WHERE name = 'Zayn';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE Employee_payroll set gender = 'M' WHERE name = 'Bill';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> INSERT INTO Employee_payroll (name, gender, salary, start) VALUES ('Shanaya', 'F', 150000.00, '2017-01-03');
Query OK, 1 row affected (0.01 sec)
mysql> select * from Employee_payroll;
+----+---------+--------+---------+------------+
| id | name | gender | salary | start |
+----+---------+--------+---------+------------+
| 1 | Raj | M | 50000 | 2022-05-01 |
| 2 | Sam | M | 55000 | 2021-12-01 |
| 4 | Zayn | M | 100000 | 2020-12-01 |
| 5 | Bill | M | 1000000 | 2018-01-03 |
| 6 | Shanaya | F | 150000 | 2017-01-03 |
+----+---------+--------+---------+------------+
5 rows in set (0.00 sec)
================================================================================================================================================
-----------------------------------------------------------------------
#UC7 ::: Performing some arithmatic operaions
----------------------------------------------------------------------
#Calculating Avg of salary of each genders
mysql> select gender, avg(salary) from Employee_payroll group by gender;
+--------+-------------+
| gender | avg(salary) |
+--------+-------------+
| M | 301250 |
| F | 150000 |
+--------+-------------+
2 rows in set (0.01 sec)
#Calculating total Avg of salary of both genders
mysql> select avg(salary) from Employee_payroll;
+-------------+
| avg(salary) |
+-------------+
| 271000 |
+-------------+
1 row in set (0.02 sec)
#Calculating total sum of salary by genders
mysql> select gender ,sum(salary) from Employee_payroll group by gender;
+--------+-------------+
| gender | sum(salary) |
+--------+-------------+
| M | 1205000 |
| F | 150000 |
+--------+-------------+
2 rows in set (0.00 sec)
#Finding Minimum salary accordingly gender from table
mysql> select gender ,min(salary) from Employee_payroll group by gender;
+--------+-------------+
| gender | min(salary) |
+--------+-------------+
| M | 50000 |
| F | 150000 |
+--------+-------------+
2 rows in set (0.00 sec)
#Finding Maximum salary accordingly gender from table
mysql> select gender ,max(salary) from Employee_payroll group by gender;
+--------+-------------+
| gender | max(salary) |
+--------+-------------+
| M | 1000000 |
| F | 150000 |
+--------+-------------+
2 rows in set (0.00 sec)
#Counting number of datas of employee present in table
mysql> select count(salary) as count_of_salary from Employee_payroll;
+-----------------+
| count_of_salary |
+-----------------+
| 5 |
+-----------------+
1 row in set (0.01 sec)
#Showing all the final data
mysql> select * from Employee_payroll;
+----+---------+--------+---------+------------+
| id | name | gender | salary | start |
+----+---------+--------+---------+------------+
| 1 | Raj | M | 50000 | 2022-05-01 |
| 2 | Sam | M | 55000 | 2021-12-01 |
| 4 | Zayn | M | 100000 | 2020-12-01 |
| 5 | Bill | M | 1000000 | 2018-01-03 |
| 6 | Shanaya | F | 150000 | 2017-01-03 |
+----+---------+--------+---------+------------+
5 rows in set (0.00 sec)
===================================================================================================================================================
**********SECTION - 2 (ER DIAGRAM)************
-----------------------------------------------------------------------
#UC8 ::: Extend table data to Adding columns phone_Number, address and department into the table
----------------------------------------------------------------------
mysql> ALTER TABLE Employee_payroll ADD Phone_Number CHAR(250) AFTER name,
-> ADD address varchar(250) AFTER Phone_Number,
-> ADD department varchar(150) NOT NULL AFTER address;
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe Employee_payroll;
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(50) | NO | | NULL | |
| Phone_Number | char(250) | YES | | NULL | |
| address | varchar(250) | YES | | NULL | |
| department | varchar(150) | NO | | NULL | |
| gender | char(1) | YES | | NULL | |
| salary | double | NO | | NULL | |
| start | date | NO | | NULL | |
+--------------+--------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)
===================================================================================================================================================
-----------------------------------------------------------------------
#UC9 ::: Extend table data to Adding columns Basic Pay, Deductions, Taxable Pay, Income tax, and Net pay into the table
----------------------------------------------------------------------
mysql> ALTER TABLE Employee_payroll
-> ADD deductions DOUBLE NOT NULL AFTER basic_pay,
-> ADD taxable_pay DOUBLE NOT NULL AFTER deductions,
-> ADD income_tax DOUBLE NOT NULL AFTER taxable_pay,
-> ADD net_pay DOUBLE NOT NULL AFTER income_tax;
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe Employee_payroll;
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(50) | NO | | NULL | |
| Phone_Number | char(250) | YES | | NULL | |
| address | varchar(250) | YES | | NULL | |
| department | varchar(150) | NO | | NULL | |
| gender | char(1) | YES | | NULL | |
| basic_pay | double | NO | | NULL | |
| deductions | double | NO | | NULL | |
| taxable_pay | double | NO | | NULL | |
| income_tax | double | NO | | NULL | |
| net_pay | double | NO | | NULL | |
| start | date | NO | | NULL | |
+--------------+--------------+------+-----+---------+----------------+
12 rows in set (0.00 sec)
===================================================================================================================================================
----------------------------------------------------------------------------------------------------
#UC10 ::: Ability to make Terissa as part of Sales and Marketing Department
----------------------------------------------------------------------------------------------------
mysql> INSERT INTO Employee_payroll(name, Phone_Number, address, department, gender, basic_pay, deductions, taxable_pay, income_tax, net_pay, start)
-> VALUES('Terissa', '1234567890', 'NewYork', 'Marketting', 'F', 3000000.00, 1000000.00, 2000000.00, 500000.00, 1500000.00, '2018-01-03'),
-> ('Terissa', '1234567890', 'NewYork', 'Sales', 'F', 30000000.00, 0, 0, 0, 0, '2019-11-13');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from Employee_payroll;
+----+---------+--------------+---------+------------+--------+-----------+------------+-------------+------------+---------+------------+
| id | name | Phone_Number | address | department | gender | basic_pay | deductions | taxable_pay | income_tax | net_pay | start |
+----+---------+--------------+---------+------------+--------+-----------+------------+-------------+------------+---------+------------+
| 1 | Raj | NULL | NULL | | M | 50000 | 0 | 0 | 0 | 0 | 2022-05-01 |
| 2 | Sam | NULL | NULL | | M | 55000 | 0 | 0 | 0 | 0 | 2021-12-01 |
| 4 | Zayn | NULL | NULL | | M | 100000 | 0 | 0 | 0 | 0 | 2020-12-01 |
| 5 | Bill | NULL | NULL | | M | 1000000 | 0 | 0 | 0 | 0 | 2018-01-03 |
| 6 | Shanaya | NULL | NULL | | F | 150000 | 0 | 0 | 0 | 0 | 2017-01-03 |
| 7 | Terissa | 1234567890 | NewYork | Marketting | F | 3000000 | 1000000 | 2000000 | 500000 | 1500000 | 2018-01-03 |
| 8 | Terissa | 1234567890 | NewYork | Sales | F | 30000000 | 0 | 0 | 0 | 0 | 2019-11-13 |
+----+---------+--------------+---------+------------+--------+-----------+------------+-------------+------------+---------+------------+
7 rows in set (0.00 sec)
===================================================================================================================================================
----------------------------------------------------------------------------------------------------
#UC11 ::: Implement the ER Diagram into Payroll Service DB with creating other tables
----------------------------------------------------------------------------------------------------
#Creating table "Company"
mysql> CREATE TABLE Company (company_ID INT PRIMARY KEY, company_Name VARCHAR(15) NOT NULL);
Query OK, 0 rows affected (0.03 sec)
mysql> SHOW TABLES;
+------------------------------------+
| Tables_in_employee_payroll_service |
+------------------------------------+
| company |
| employee_payroll |
+------------------------------------+
2 rows in set (0.00 sec)
mysql> DESCRIBE company;
+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| company_ID | int | NO | PRI | NULL | |
| company_Name | varchar(15) | NO | | NULL | |
+--------------+-------------+------+-----+---------+-------+
2 rows in set (0.01 sec)
---------------------------------------------
#Creating employee table
mysql> CREATE TABLE employee (ID INT unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, company_ID INT,
-> phone_number varchar(250),
-> address varchar(250),
-> gender char(1),
-> Name varchar(150) NOT NULL,
-> FOREIGN KEY (company_ID) REFERENCES company (company_ID)
-> );
Query OK, 0 rows affected (0.05 sec)
mysql> describe employee;
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| ID | int unsigned | NO | PRI | NULL | auto_increment |
| company_ID | int | YES | MUL | NULL | |
| phone_number | varchar(250) | YES | | NULL | |
| address | varchar(250) | YES | | NULL | |
| gender | char(1) | YES | | NULL | |
| Name | varchar(150) | NO | | NULL | |
+--------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
----------------------------------
#Creating Payroll table
mysql> CREATE TABLE payroll
-> (
-> ID INT unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> FOREIGN KEY (ID) REFERENCES employee (ID),
-> basic_pay DOUBLE NOT NULL,
-> deductions DOUBLE NOT NULL,
-> taxable_pay DOUBLE NOT NULL,
-> tax DOUBLE NOT NULL,
-> net_pay DOUBLE NOT NULL
-> );
Query OK, 0 rows affected (0.03 sec)
mysql> describe payroll;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| ID | int unsigned | NO | PRI | NULL | auto_increment |
| basic_pay | double | NO | | NULL | |
| deductions | double | NO | | NULL | |
| taxable_pay | double | NO | | NULL | |
| tax | double | NO | | NULL | |
| net_pay | double | NO | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
-------------------------------------------
#Creating table Department
mysql> CREATE TABLE department(
-> Department_ID int NOT NULL PRIMARY KEY,
-> Department_Name varchar(150) NOT NULL
-> );
Query OK, 0 rows affected (0.02 sec)
mysql> describe department;
+-----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| Department_ID | int | NO | PRI | NULL | |
| Department_Name | varchar(150) | NO | | NULL | |
+-----------------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
--------------------------------------------
#Creating table employee_department
mysql> create table employee_department(
-> ID INT unsigned NOT NULL AUTO_INCREMENT,
-> FOREIGN KEY (ID) REFERENCES employee (ID),
-> Department_ID int NOT NULL,
-> FOREIGN KEY (Department_ID) REFERENCES department (Department_ID)
-> );
Query OK, 0 rows affected (0.06 sec)
mysql> describe employee_department;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| ID | int unsigned | NO | MUL | NULL | auto_increment |
| Department_ID | int | NO | MUL | NULL | |
+---------------+--------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
======================================================================
#UC12 ::: Adding data into the corresponding created tables
----------------------------------------------------------------------------------------------------
#Adding data into table "Company"
mysql> INSERT INTO company VALUES
-> (1,'Capgemini'),
-> (2,'Microsoft'),
-> (3,'Reliance');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from company;
+------------+--------------+
| company_ID | company_Name |
+------------+--------------+
| 1 | Capgemini |
| 2 | Microsoft |
| 3 | Reliance |
+------------+--------------+
3 rows in set (0.00 sec)
-----------------------------------------------------
#Adding data into table "Employee"
mysql> INSERT INTO employee VALUES
-> (101,1,'8886771','Hyderabad','F','Shreya'),
-> (102,2,'4567823','Mumbai','F','Neha'),
-> (103,3,'4567828','Pune','M','Rajiv');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from employee;
+-----+------------+--------------+-----------+--------+--------+
| ID | company_ID | phone_number | address | gender | Name |
+-----+------------+--------------+-----------+--------+--------+
| 101 | 1 | 8886771 | Hyderabad | F | Shreya |
| 102 | 2 | 4567823 | Mumbai | F | Neha |
| 103 | 3 | 4567828 | Pune | M | Rajiv |
+-----+------------+--------------+-----------+--------+--------+
3 rows in set (0.00 sec)
-----------------------------------------------------
#Adding data into table "payroll"
mysql> INSERT INTO payroll VALUES
-> (101,50000,5000,45000,5000,40000),
-> (102,20000,2000,18000,3000,15000),
-> (103,60000,6000,54000,4000,50000);
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from payroll;
+-----+-----------+------------+-------------+------+---------+
| ID | basic_pay | deductions | taxable_pay | tax | net_pay |
+-----+-----------+------------+-------------+------+---------+
| 101 | 50000 | 5000 | 45000 | 5000 | 40000 |
| 102 | 20000 | 2000 | 18000 | 3000 | 15000 |
| 103 | 60000 | 6000 | 54000 | 4000 | 50000 |
+-----+-----------+------------+-------------+------+---------+
3 rows in set (0.00 sec)
-------------------------------------------------------------------
#Adding data into table "department"
mysql> INSERT INTO department VALUES
-> (21,'AI'),
-> (22,'CSE'),
-> (23,'Sales and Marketing');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from department;
+---------------+---------------------+
| Department_ID | Department_Name |
+---------------+---------------------+
| 21 | AI |
| 22 | CSE |
| 23 | Sales and Marketing |
+---------------+---------------------+
3 rows in set (0.00 sec)
---------------------------------------------------
#Adding data into table "employee_department"
mysql> INSERT INTO employee_department VALUES
-> (101,21),
-> (102,22),
-> (103,23),
-> (102,21);
Query OK, 4 rows affected (0.01 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> select * from employee_department;
+-----+---------------+
| ID | Department_ID |
+-----+---------------+
| 101 | 21 |
| 102 | 22 |
| 103 | 23 |
| 102 | 21 |
+-----+---------------+
4 rows in set (0.00 sec)
============================================================================================================================================