Lab 2
Lab 2
Employee:
Fname Lname SSN BDATE Addresss Sex Salary Superssn Dno
Ahmed Ali 112233 1/1/196515 Ali fahmy M 1300 223344 10
St.Giza
Kamel Mohamed 223344 15/10/1970 38 Mohy el dien M 1800 321654 10
abo el Ezz
St.Cairo
Hanaa Sobhy 123456 18/3/1973 38 Abdel Khalik F 800 223344 10
Tharwat St.
Downtown.Cairo
Amr Omran 321654 14/9/1963 44 Hilopolis.Cairo M 2500 null null
Noha Mohamed 968574 1/2/1975 55 Orabi St. El F 1600 321654 20
Mohandiseen
.Cairo
Edward Hanna 512463 19/8/1972 18 Abaas El M 1500 321654 30
3akaad St. Nasr
City.Cairo
Mariam Adel 669955 12/6/1982 269 El-Haram st. F 750 512463 20
Giza
Maged Raoof 521634 6/4/1980 18 Kholosi M 1000 968574 30
st.Shobra.Cairo
Department
Dname DNum MGRSSN MGRStart Date
Project
Pname Pnumber Plocation City Dnum
AL Solimaniah 100 Cairo_Alex Road Alex 10
Al Rabwah 200 6th of October Giza 10
City
Al Rawdah 300 Zaied City Giza 10
Al Rowad 400 Cairo_Faiyom Giza 20
Road
Al Rehab 500 Nasr City Cairo 30
Pitcho american 600 Maady Cairo 30
Ebad El 700 Ring Road Cairo 20
Rahman
Dependent
ESSN Dependent_name Sex Bdate
112233 Hala Saied Ali F 18/10/1970
223344 Ahmed Kamel M 27/3/1998
Shawki
223344 Mona Adel F 25/4/1975
Mohamed
321654 Ramy Amr M 26/1/1990
Omran
321654 Omar Amr Omran M 30/3/1993
321654 Sanaa Gawish F 16/5/1973
512463 Sara Edward F 15/9/2001
512463 Nora Ghaly F 22/6/1976
Data Manipulating Language:
1. Insert your personal data to the employee table as a new employee in department
number 30, SSN = 102672, Superssn = 112233.
UPDATE employee set
fname='doha',lname='magdi',bdate='1999/1/23',address='operacity',sex='f',salary=200
00 where ssn=102672;
2. Insert another employee with your friend personal data as new employee in
department number 30, SSN = 102660, but don’t enter any value for salary or
supervisor number to him but fill all other fields with dummy data.
INSERT INTO employee(ssn,superssn,dno)VALUES(102672,112233,30)
3. In the department table insert new department called "DEPT IT", with id 100,
employee with SSN = 112233 as a manager for this department. The start date for this
manager is '1-11-2006'
a. First try to update her record in the department table UPDATE departments
set mgrssn=968574 WHERE DNUM=100;
b. Update your record to be department 20 manager. UPDATE departments set
mgrssn=102672 WHERE DNUM=20;
c. Update your friend data (entered in question2) to be in your teamwork
(supervised by you) UPDATE employee set superssn=102672 where
ssn=102660;
5. Unfortunately, the company ended the contract with Mr. Kamel Mohamed
(SSN=223344) so try to delete his data from your database in case you know that
your friend (SSN entered in question2) will be temporarily in his position.
Hint: (Check if Mr. Kamel has dependents, works as a department manager,
supervises any employees or works in any projects and handle these cases).
DELETE FROM dependent WHERE ESSN=223344;
DELETE FROM works_for WHERE ESSN=223344;
UPDATE departments set mgrssn=102660 WHERE dnum=10;
UPDATE employee set superssn=102660 WHERE superssn=223344;
DELETE FROM employee WHERE SSN=223344;
6.And your salary has been upgraded by 20 percent of its last value.
UPDATE employee set salary=salary+(salary*0.2) WHERE ssn=102672