Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
40 views35 pages

ISM

The document appears to be a practical file for a Bachelor of Business Administration degree. It contains details of various SQL queries and commands practiced as part of an ISM (Information Systems Management) course. The practical file covers basic SQL commands like CREATE TABLE and INSERT, as well as more advanced topics like JOINs, aggregate functions, and modifying database structures. Sample databases on students, employees and companies are used to demonstrate the SQL queries and analyze the results.

Uploaded by

preeti Kr.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views35 pages

ISM

The document appears to be a practical file for a Bachelor of Business Administration degree. It contains details of various SQL queries and commands practiced as part of an ISM (Information Systems Management) course. The practical file covers basic SQL commands like CREATE TABLE and INSERT, as well as more advanced topics like JOINs, aggregate functions, and modifying database structures. Sample databases on students, employees and companies are used to demonstrate the SQL queries and analyze the results.

Uploaded by

preeti Kr.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Practical file of ISM

for the of

BACHELOR OF BUSINESS ADMINISTRATION (BBA)

SUBMITTED BY

PREETI
ENROLLMENT NO.: 00791101721

UNDER THE GUIDANCE OF

Ms. HARJOT KAUR

SRI GURU TEGH BAHADUR INSTITUTE OF MANAGEMENT

& INFORMATION TECHNOLOGY

(AFFILIATED TO GURU GOBIND SINGH

INDRAPRASTHA UNIVERSITY, DELHI)

(2021-2024)
ISM PRACTICAL QUESTIONS

PRACTICAL 1

To study the basic commands of SQL i.e., CREATE TABLE, INSERT, execute the
following queries using SQL commands:

(I). CREATE TABLE STUDENTS with attributes s_NAME,s_CITY, s_NUMBER,


s_ADDRESS, s_COURSE .

CODE:

CREATE TABLE STUDENTS(NAME varchar(250), CITY varchar(250), NUMBER INT,


ADDRESS varchar(800), COURSE varchar(250),);

RESULT:
(II). INSERT INTO STUDENTS
VALUES(s_NAME,s_CITY,s_NUMBER,s_ADDRESS,s_COURSENAME,)

CODE:

INSERT INTO STUDENTS VALUES(‘Aman', 'DELHI', 9765543651, 'Shastri nagar’,


‘BCA’, );

INSERT INTO STUDENTS VALUES('Nyra', ‘DELHI', 9234543651, 'Shastri nagar',


'B.Comm.',);

INSERT INTO STUDENTS VALUES(‘Naman', ‘DELHI', 9987587656, 'Karol bagh',


'B.B.A.(B&I)',);

INSERT INTO STUDENTS VALUES('Kartik', 'DELHI', 9987653456,’Moti nagar’, 'LLB',);

INSERT INTO STUDENTS VALUES('Bhuvi', 'DELHI', 9872143653, 'Kirti nagar', 'MBA',

); INSERT INTO STUDENTS VALUES('Aditi', 'Delhi', 9176643651, 'Patel nagar', 'MCA',

); INSERT INTO STUDENTS VALUES('Dhruv', ' DELHI', 9676543651, 'Rajinder

nagar',); INSERT INTO STUDENTS VALUES('Manik', 'DELHI', 9876543651, 'nsp',

'B.B.A.';);

INSERT INTO STUDENTS VALUES('Armaan', 'DELHI', 9276543651, 'Shahrdra',


'B.Pharma', );

INSERT INTO STUDENTS VALUES('Kirti', 'DELHI', 957654365, 'Moti nagar', 'BMS', );

RESULT:
(III). DISPLAY TABLE STUDENTS

SELECT * FROM table_name

CODE:

SELECT * FROM STUDENTS

RESULT:
PRACTICAL -2

To study viewing commands (select, update) and execute the following queries
using these commands:

(I). Find the names of all employees who live in New Delhi.

CODE:

SELECT NAME from EMPLOYEES where CITY='NEW_DELHI';

RESULT:

(II). Increase the salary of all employees by rupees 5000.

CODE:

UPDATE emp SET salary = salary+5000;


RESULT:
(iii). Find the company names where number of employees is greater than 10000.

CODE:

select c_name from company where number_of_employees>=10000;

Result:
(IV). Change the company city to ‘Gurgaon’ where company name is ‘TCS’.

CODE: update company set c_city = 'Gurgaon' where c_name = 'TCS';

RESULT:
PRACTICAL -3

To study command to modify the structure of table (alter, delete) and execute
the following commands:

(I). Add an attribute named ‘CONTACT_NUMBER’ to the table ‘EMPLOYEES’.

CODE:

ALTER TABLE EMPLOYEES ADD CONTACT_NUMBER INT;

RESULT

(II). Drop attribute 'CONTACT_NUMBER' from table ‘EMPLOYEES’.

CODE:

ALTER TABLE EMPLOYEES DROP COLUMN CONTACT_NUMBER;

RESULT:
PRACTICAL -4

To study the commands that involves compound conditions and, or, in, not in,
between, not between, like, not like and execute the following queries using
these commands:

(I). Find the names of all the employees who live in Gurgaon and whose salary is
between 20000 and 30000.

CODE:

SELECT * FROM EMPLOYEES where SALARY > 20000 and salary < 30000 and
CITY='GURUGRAM';

RESULT:

(ii). Find the names of all the employees whose name begin with letter ‘S’ or ‘J’.

CODE:
Select * from emp where e_name like "S%" or e_name like "J%";

(iii). Find company names where company city is New Delhi and number of
employees is not between 5000 and 10000.

CODE:

Select * from company where c_city = 'New Delhi' and number_of_employees


NOT BETWEEN 5000 and 10000;

CREATE TABLE company( c_name varchar(150), c_city varchar(150),


number_of_employees int);

INSERT INTO company VALUES ('Wipro','New-Delhi',11000);

INSERT INTO company VALUES ('Sony','Noida',12000);

INSERT INTO company VALUES ('LG','Gurugram',15000);

INSERT INTO company VALUES ('TCS','Noida',1000);


INSERT INTO company VALUES ('Sony','New Delhi',13000);

INSERT INTO company VALUES ('LG','Faridabad',13000);

INSERT INTO company VALUES ('Wipro','Mumbai',14000);

INSERT INTO company VALUES ('LG','Chandigarh',10000);

INSERT INTO company VALUES ('TCS','Mumbai',8000);

INSERT INTO company VALUES ('Wipro','Chandigarh',7500);

SELECT * from company

SELECT * from company where c_city = 'New-Delhi' and number_of_employees


NOT BETWEEN 5000 and 10000;
(iv). Find name of all companies that do not end with letter ‘A’.

CODE:

Select * from company where c_city not like ‘/A’;


Practical 5

To study aggregate functions (sum, count, max, min, avg) and execute the
following queries using these commands:

(i). Find sum and average of the salary of all the employees of marketing
department.

CODE:

SELECT sum(e_salary) FROM emp where e_department='Marketing';

SELECT avg(salary) FROM emp where e_department='Marketing';


(ii). Find number of employees who live in New Delhi.

CODE:

SELECT COUNT(e_name) FROM emp WHERE e_city='new delhi';

(iii). Find maximum and minimum salary of Human Resource department.

CODE:
SELECT max(e_salary) FROM emp where e_department='HR';

SELECT min(e_salary) FROM emp where e_department='HR';


Practical 7

ER DIAGRAM

Represent each of the following requirements in ER diagram:

A regional council requires the design of database system that can provide
information on all schools in the region. The requirement collection and analysis
phase of the database design process has been provided in the form of following
requirement

1. Every school has many pupils and many teachers. Each pupil is assigned to 1
school and each teacher works for one school only.
2. Each teacher teaches more than 1 subject but the subject may be taught by
more than 1 teacher. The database should store the number of hour the
teacher spending a teaching a subject. Data held on each teacher includes his
or her National Insurance Number (NIN), Name (first, last), sex (M/F) and
qualifications. The data held on each subject include subject title and type.
3. Each pupil can study more than 1 subject and subject may be studied by more
than 1 pupil. Data held on each pupil includes the pupils code, Name (first, last),
sex (M/F), Date of birth.

Each school is managed by one of its teachers. The database should keep the
record of the day when he/ she started managing the school. Data stored on each
school include school code, name, address (town, street, postal code &phone
no.).
Practical 8

Table – EmployeeDetails

EmpId FullName ManagerId DateOfJoining City

121 John Snow 321 01/31/2014 Toronto

321 Walter White 986 01/30/2015 California

421 Kuldeep Rana 876 27/11/2016 New Delhi

Table – EmployeeSalary

EmpId Project Salary Variable

121 P1 8000 500

321 P2 10000 1000

421 P1 12000 0
CREATE TABLE EmployeeDetails (EmpId int, FullNAME Varchar , ManagerId ,
DateOfJoining varchar(30), City Varchar (100));

INSERT INTO EmployeeDetails VALUES('121','John


Snow','321','01/31/2014','Toronto');

INSERT INTO EmployeeDetails VALUES('321','Walter


White','986','01/30.2015','California');

INSERT INTO EmployeeDetails VALUES('421','Kuldeep


Rana','876','27/11/2016','New Delhi');

SELECT * from EmployeeDetails;

CREATE TABLE EmployeeSalary (EmplId int, Project varchar(150), Salary int,


Variable varchar(30));
INSERT INTO EmployeeSalary VALUES('121','P1','8000','500');

INSERT INTO EmployeeSalary VALUES('321','P2','10000','1000');

INSERT INTO EmployeeSalary VALUES('421','P3','12000','0');

SELECT DISTINCT(Project) FROM EmployeeSalary;

Ques.1. Write an SQL query to fetch the EmpId and FullName of all the
employees working under Manager with id – ‘986’

Code : SELECT emplId, FullName FROM EmployeeDetails WHERE ManagerId = 986;


Ques.2. Write an SQL query to fetch the different projects available from the
EmployeeSalary table.

Ans. While referring to the EmployeeSalary table, we can see that this table
contains project values corresponding to each employee, or we can say that we
will have duplicate project values while selecting Project values from this table.

So, we will use the distinct clause to get the unique values of the Project.

CODE: SELECT DISTINCT(Project) FROM EmployeeSalary;


Ques.3. Write an SQL query to fetch the count of employees working in project
‘P1’.
Ans. Here, we would be using aggregate function count() with the
SQL where clause –

Code : SELECT COUNT (*) FROM EmployeeSalary WHERE Project='P1';


Ques.4. Write an SQL query to find the maximum, minimum, and average salary
of the employees.
Ans. We can use the aggregate function of SQL to fetch the max, min, and average
values-
Code : SELECT max(Salary) FROM EmployeeSalary ;
Min(Salary),

Code : SELECT min(Salary) FROM EmployeeSalary ;


AVG(Salary)

Code : SELECT avg(Salary) FROM EmployeeSalary ;

Ques.5. Write an SQL query to find the employee id whose salary lies in the
range of 9000 and 15000.
Ans. Here, we can use the ‘Between’ operator with a where clause.

Code : SELECT * from EmployeeSalary where Salary > 9000 and Salary < 15000;
Ques.6. Write an SQL query to fetch those employees who live in Toronto and
work under manager with ManagerId – 321.

Ans. Since we have to satisfy both the conditions – employees living in ‘Toronto’
and work under manager with ManagerId – 321.. So, we will use AND operator here
-

Code : Select * from EmployeeDetails where city = 'Toronto' and ManagerId ='321';
Ques.7. Write an SQL query to fetch all the employees who either live in
California or work under a manager with ManagerId – 321.
Ans. This interview question requires us to satisfy either of the conditions –
employees living in ‘California’ and working under Manager with ManagerId ‘321’.
So, we will use the OR operator here-

Code : Select * from EmployeeDetails where city = 'California' or ManagerId ='321';


Ques.8. Write an SQL query to fetch all those employees who work on Project
other than P1.
Ans. Here, we can use the NOT operator to fetch the rows which are not satisfying
the given condition.

Code : SELECT EmplId from EmployeeSalary where NOT Project='P1';


Ques.9. Write an SQL query to fetch the employees whose name begins with
any two characters, followed by a text “hn” and ending with any sequence of
characters.
Ans. For this question, we can create an SQL query using like operator with ‘_’ and
‘%’ wild card characters, where ‘_’ matches a single character and ‘%’ matches ‘0
or multiple characters’.

Code :

SELECT FullName FROM EmployeeDetails WHERE FullName LIKE ‘ hn%’;


Ques.10. Write an SQL query to fetch all the EmpIds which are present in either
of the tables – ‘EmployeeDetails’ and ‘EmployeeSalary’.
Ans. In order to get unique employee ids from both the tables, we can use Union
clause which can combine the results of the two SQL queries and return unique
rows.

Code : SELECT emplId FROM EmployeeDetails UNION SELECT EmpId FROM


EmployeeSalary;

Ques.11. Write an SQL query to fetch the employee full names and replace the
space with ‘-’.
Ans. Using ‘Replace’ function -

Code : SELECT REPLACE(FullName, ' ', '-') FROM EmployeeDetails;


Ques.12. Write an SQL query to upper case the name of the employee and lower
case the city values.
Ans. We can use SQL Upper and Lower functions to achieve the intended results.

Code: SELECT UPPER(FullName), LOWER(City) FROM EmployeeDetails;


Ques.13. Write an SQL query to fetch all the Employees details from
EmployeeDetails table who joined in the Year 2020.

Code : Select * from EmployeeDetails where DateOfJoining between


'2020/01/01' AND '2020/12/31';
QUES 14. Write an SQL query to increase the salary of all employees by RS 10000

Code : UPDATE EmployeeSalary SET salary = salary+10000

You might also like