0% found this document useful (0 votes)
6 views9 pages

Soumyadeep Ganguly 24MDT0082

The document outlines SQL and MongoDB tasks performed by Soumyadeep Ganguly, including creating tables, inserting data, querying employee and project information, and manipulating records. It details the creation of a student database in MongoDB, insertion of student records, and various queries to retrieve and update student information. Additionally, it includes PL/SQL procedures for adding bonuses and deleting records in the employee table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Soumyadeep Ganguly 24MDT0082

The document outlines SQL and MongoDB tasks performed by Soumyadeep Ganguly, including creating tables, inserting data, querying employee and project information, and manipulating records. It details the creation of a student database in MongoDB, insertion of student records, and various queries to retrieve and update student information. Additionally, it includes PL/SQL procedures for adding bonuses and deleting records in the employee table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Name: Soumyadeep Ganguly

Reg No: 24MDT0082


DBMS Lab CAT

1.
A. Create the two tables with the given schemas.

Create Employee table:

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 Project table:

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.

Insert data into employee table:

insert into employee values(1, 'Alice', 'HR', 50000, '10-jan-2021');

insert into employee values(2, 'Bob', 'IT', 70000, '15-may-2020');

insert into employee values(3, 'Carol', 'Finance', 60000, '20-jul-2022');

insert into employee values(4, 'Dave', 'Marketing', 55000, '25-mar-2019');

insert into employee values(5, 'Eve', 'IT', 75000, '30-nov-2018');


Insert data into project table:

insert into project values(101, 'Alpha', '01-jan-2022', 100000, 1);

insert into project values(102, 'Beta', '15-feb-2023', 150000, 2);

insert into project values(103, 'Gamma', '10-mar-2022', 200000, 3);

insert into project values(104, 'Delta', '25-jun-2021', 120000, 4);

insert into project values(105, 'Epsilon', '05-sep-2023', 175000, 5);

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.

Query: select sum(salary) from employee;

E. Write an SQL query to find all


employees who do not have any project assigned using Subquery concept.
Query: select * from employee where empid not in (select empid from project);

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: use student;

Creating collection Students:

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}});

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy