Soumyadeep Ganguly 24MDT0082
Soumyadeep Ganguly 24MDT0082
1.
A. Create the two tables with the given schemas.
create table employee(empid number(5) primary key not null,name varchar2(20) not null,
department varchar2(20), salary number(10,2), hiredate date not null);
create table project(projectid number(5) primary key not null,projectname varchar2(20) not null,
startdate date, budget number(10,2), empid number(5));
B. Insert the following rows to the employee table you have created.
C. Print the details of the employees with a salary greater than or equal to 60,000 and less than
80,000.
Query: select * from employee where salary between 60000 and 80000;
D. Retrieve and print the sum of the salary of all the employees.
F. Write a PL/SQL procedure Add_Bonus that adds a bonus of 5000 to employees who
joined before 2021. Run the procedure and print the updated table.
PL/SQL Code:
create or replace procedure addbonus is
begin
for i in (select * from employee where hiredate < todate('01-jan-2021')) loop
i.salary := i.salary + 5000;
endloop;
end;
/
G. Delete the record of the employee named 'Dave'.
Query: delete from employee where name='Dave';
2. MongoDB
A. Create a database student and a collection STUDENTS in it using MongoDB shell.
Provide screenshots of the output of your query in mongosh.
Creating Student Database:
Command: db.createCollection('students');
B. Insert the following documents into your collection STUDENTS. Show the
screenshots of the same.
Inserting One Row:
db.students.insertOne({"StudentID": 1, "Name": "John", "Major": "Computer Science",
"GPA": 3.8,"EnrollmentDate": "2020-01-15"});
Inserting many rows:
db.students.insertMany([{"StudentID": 2, "Name": "Emily","Major": "Electrical
Engineering","GPA":3.5,"EnrollmentDate":"2020-01-15"},{"StudentID": 3,"Name":"Michael",
"Major":"Mechanical Engineering", "GPA":3.9, "EnrollmentDate":"2022-03-
20"},{"StudentID": 4,"Name": "Sophia","Major":"Civil Engineering", "GPA": 3.7,
"EnrollmentDate": "2019-05-10"}, {"StudentID":5, "Name":"David", "Major":"Computer
Science", "GPA":3.2, "EnrollmentDate":"2021-08-25"}]);
C. Retrieve and print the details of all students in the "Computer Science" major. (2 marks)
db.students.find({"Major":"Computer Science"});
D. Find the names of students who have a GPA greater than or equal to 3.7. (2 marks)
db.students.find({"GPA":{$gte:3.7}});
E. Increase the GPA of all students in the "Electrical Engineering" major by 0.1. (2
marks)
F. Delete the document of the student named "Sophia" and print all the
documents available in your updated collection. (2 marks)
db.students.deleteOne({"Name":"Sophia"});
db.students.find();
G. Update the GPA of the student with StudentID 1 to 4.0. (2 marks)
db.students.updateOne({"StudentID":1},{$set:{"GPA":4.0}});