ISM Govind Singh

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 26

PRACTICAL FILE

OF
INFORMATION SYSTEM MANAGEMENT LAB (BBA 212)

Degree of BBA 2021-2024

UNDER THE GUIDANCE OF: SUBMITTED BY:


MS. DIMPY JINDAL VAIBHAV DESHWAL
(Assistant Professor) 35112301721

DELHI INSTITUTE OF ADVANCED STUDIES


Plot No. 6, Sector-25, Rohini, Delhi-110085
(Approved by AICTE & Affiliated with GGSIP University for B.COM (H), BBA and MBA
(FM) Programmes)
(An ISO 9001:2015 Certified Institution)
QUES 1. Difference between DDL and DML.

Data Definition Language


DDL is used to define data structures. It is used to create database schema and can be
used to define some constraints as well. It defines the column (Attributes) of the table.
It doesn’t have any further classification.
DDL does not use WHERE clause in its statement.DDL is used to define the structure
of a database.DDL is used to create and modify database objects like tables, indexes,
views, and constraints.

 Examples of DDL commands: CREATE TABLE, ALTER TABLE, DROP


TABLE, TRUNCATE TABLE, and RENAME TABLE.

1. CREATE TABLE: This command is used to create a new table in SQL. The user
must give information like table name, column names, and their data types.
SYNTAX:
CREATE TABLE <table_name>
(column_1 datatype,
column_2 datatype,
column_3 datatype);
EXAMPLE:
CREATE TABLE <Student_info>
(College_Id int,
College_name varchar(30),
Branch varchar(10));

2. ALTER TABLE: This command is used to add, delete, or change columns in the
existing table. The user needs to know the existing table name and can do add,
delete, or modify tasks easily.
SYNTAX: To add a column to an existing table.
ALTER TABLE <table_name>
ADD column_namedatatype;
EXAMPLE:
ALTER TABLE Student ADD Father's_Name VARCHAR(60);

 ALTER COLUMN: Command is used to change the data type of a column in a


table.
SYNTAX:
ALTER TABLE <table_name>
ALTER COLUMN <column_name>;
EXAMPLE:
ALTER TABLE Employees
ALTER COLUMN BirthDate year;

3. DROP TABLE: It is used to delete both the structure and record stored in the
table.
SYNTAX:
DROP TABLE <table_name>;
EXAMPLE:
DROP TABLE Student;

4. TRUNCATE TABLE: It is used to delete all the rows from the table and free the
space containing the table.
SYNTAX:
TRUNCATE TABLE <table_name>;
EXAMPLE:
TRUNCATE TABLE Student;
5. RENAME TABLE: RENAME TABLE allows you to rename an existing table
in any schema. To rename a table, you must either be the database owner or the
table owner.
SYNTAX:
RENAME <old_table _name> TO <new_table_name>;
EXAMPLE:
RENAME student TO Student_Table;

Data Manipulation Language


DML is used to manipulate data within the database. It is used to add, retrieve, or update
the data. It adds or updates the row of the table. These rows are called tuple.
DML uses WHERE clause in its statement. DML statements are used to manipulate data
directly.

 Examples of DML commands: SELECT, INSERT, UPDATE, DELETE, and


MERGE.

1. SELECT: It is the most important data manipulation command in Structured


Query Language. The SELECT command shows the records of the specified table.
It also shows the particular record of a particular column by using the WHERE
clause.
SYNTAX:
1. SELECT <column_Name_1, column_Name_2>FROM <table_name>;
2. SELECT * FROM <table_name>;

EXAMPLE:
1. SELECT Emp_Id, Emp_Salary FROM Employee;
2. SELECT * FROM Student;

2. INSERT: It is another most important data manipulation command in Structured


Query Language, which allows users to insert data in database tables.
SYNTAX:
INSERT INTO <table_name> (column_name1, column_name2) VALUES (value_1,
value_2);
EXAMPLE:
INSERT INTO Student (Name char(20), Roll int) VALUES (‘Anushka’, 1);

3. UPDATE: It is another most important data manipulation command in Structured


Query Language, which allows users to update or modify the existing data in
database tables.
SYNTAX:
UPDATE <table_name> SET (column_name1= value_1,column_name2 = value_2]
WHERE condition;
EXAMPLE:
UPDATE Student SET Contact = ‘9810’ WHERE Roll=2;

4. DELETE: It is a DML command which allows SQL users to remove single or


multiple existing records from the database tables. This command of Data
Manipulation Language does not delete the stored data permanently from the
database. We use the WHERE clause with the DELETE command to select
specific rows from the table.
SYNTAX:
DELETE FROM <table_name> WHERE condition;
EXAMPLE:
DELETE FROM Student WHERE Name= 'XYZ';

5. MERGE: Merge in SQL merges two tables, a TARGET table, and a SOURCE
table, to form a single TARGET table where entries are INSERTED, DELETED,
or UPDATED based on their presence or absence on the source table.
CLAUSES: It is a built-in function that is used to retrieve the data from the records
present in the database. Different clauses in SQL are used to fetch or retrieve the records
from the database table.
 Examples: ORDER BY, GROUP BY, WHERE, AND, OR.

1. ORDER BY: This keyword is used to sort the result-set in ascending or


descending order. The ORDER BY keyword sorts the records in ascending order
by default.
SYNTAX:
SELECT * FROM <table_name>
ORDER BY <column_name>;
EXAMPLE:
SELECT * FROM Students
ORDER BY Name;

 DESC: The ORDER BY keyword sorts the records in ascending order by default.
To sort the records in descending order, use the DESC keyword.
SYNTAX:
SELECT * FROM <table_name>
ORDER BY <column_name> DESC ;
EXAMPLE:
SELECT * FROM Students
ORDER BY Roll_no DESC;

2. GROUP BY:It groups rows that have the same values into summary rows. It is
often used with aggregate functions like COUNT(), MAX(), MIN(), SUM(),
AVG() to group the result-set by one or more columns.

SYNTAX:
SELECT <column_name>
FROM <table_name>
WHERE <condition>
GROUP BY <column_name>
ORDER BY <column_name>;

EXAMPLE:

SELECT COUNT (Stud_ID), Address


FROM Students
GROUP BY Address;

QUES 2. Create a local template of "FACULTY", insert 5 records and perform the
following queries on faculty template table:
a. Insert five records using "new faculty" tab in faculty template.
b. Faculty name should be in ascending order.
c. Department should be in descending order.
d. Generate report for: All faculty category and faculty by department category.

ANS.

 Use mysql

 Show databases
 Show tables

 Create table ‘Faculty’.

 Desc ‘Faculty’.
a. Insert five records using "new faculty" tab in faculty template.

 Alter table ‘Faculty’ Rename column Subject to Department.

b. Faculty name should be in ascending order.


c. Department should be in descending order.

d. Generate report for: All faculty category and faculty by department category.

QUES 3.Create a table employee with the following fields:


 Emp_id
 Emp_name
 Contact no.
 Gender
 Salary
 Emp_grade
 Designation
 Address
Execute the following queries on the table created:
a. Display the details of the employees
b. Display the ‘Employees’ id of employee whose name is ‘Ekta’.
c. Display the name of the employee whose contact no. is 456.
d. Display the details of the employee whose address is Chhatarpur.
e. Display the name of the employees whose salary is greater than 3,00,000.
f. Update the employee details, set EMP GRADE equal to C whose salary is less than
1,00,000.
g. Delete the record of the employee whose gender is male and designation is
manager
h. Display the name, designation, and salary of all the employees whose names
begins with A.
i. Update the employee details; set designation to Assistant Manager where
designation is Librarian.

 Use mysql.
 Show databases.

 Show tables.

 Create table ‘Employees’.


 Insert into Employees.

(a) Display the details of the employees

(b) Display the ‘Employees’ id of employee whose name is ‘Ekta’.

(c) Display the name of the employee whose contact no. is 456.
(d) Display the details of the employee whose address is Chhatarpur.

(e) Display the name of the employees whose salary is greater than 3,00,000.
(f) Update the employee details, set EMP GRADE equal to 3 whose salary is less
than 1,00,000.

(g) Delete the record of the employee whose gender is male and designation is
Financial Analyst.

(h) Display the name, designation, and salary of all the employees whose names
begins with A.
(i) Update the employee details, set designation to Assistant Manager where
designation is Librarian.

QUES 4. Design ER Diagram.


Assume we have the following application that models soccer teams, the games they
play, and the players in each team. In the design, we want to capture the following:

 We have a set of teams, each team has an ID (unique identifier), name, main
stadium, and to which city this team belongs.
 Each team has many players, and each player belongs to one team. Each
player has a number (unique identifier), name, DOB, start year, and shirt
number that he uses.
 Teams play matches, in each match there is a host team and a guest team. The
match takes place in the stadium of the host team.
 For each match we need to keep track of the following:
 The date on which the game is played
 The final result of the match
 The players participated in the match. For each player, how many goals he
scored, whether or not he took yellow card, and whether or not he took red
card.
 During the match, one player may substitute another player. We want to
capture this substitution and the time at which it took place.
 Each match has exactly three referees. For each referee we have an ID
(unique identifier), name, DOB, years of experience. One referee is the main
referee and the other two are assistant referee.
Design an ER diagram to capture the above requirements. State any assumptions
you have that affects your design (use the back of the page if needed). Make sure
cardinalities and primary keys are clear.
QUES 5. Create a table Employee to store employee details as shown below and
write statements for following queries based on the table.

Consider the Employee table and write SQL command to get the following.
a. Write a query to display Ename and Sal of employees whose salary are greater
than or equal to 2200?
b. Write a query to display details of employees who are not getting commission?
c. Write a query to display employee name and salary of those employees who don’t
have their salary in range of 2500 to 4000?
d. Write a query to display the name, job title and salary of employees who don’t
have manager?
e. Write a query to display the name of employee whose name contains “A” as third
alphabet?
f. Write a query to display the name of employee whose name contains “T” as last
alphabet?
g. Write a query to display the name of employee whose name contains ”M” as First
and “L” as third alphabet?
 Use mysql and show databases.

 Show tables.
 CREATE TABLE Employee.

 INSERT INTO Employee.

a. Write a query to display E_name and Salary of employees whose salary are
greater than or equal to 2200.
b. Write a query to display details of employees who are not getting commission?

c. Write a query to display employee name and salary of those employees who don’t
have their salary in range of 2500 to 4000?

d. Write a query to display the name, job title and salary of employees who don’t
have manager?
e. Write a query to display the name of employee whose name contains ‘A’ as third
alphabet?

f. Write a query to display the name of employee whose name contains ‘T’ as last
alphabet?

g. Write a query to display the name of employee whose name contains ‘M’ as First
and ‘L’ as third alphabet?

OR
QUES 6. Create a table Student with following fields:
 Enrolment_No.
 S_Name
 Course_ID
 Batch
 Semester
Execute the following queries after entering 10 records in the table.
a. Display the list of Students in Batch ‘2017-2020’.
b. Display the Enrolment No of 4th semester students.
c. Display the list of students of batch ‘2019-2022’ and Course_ID 17.
d. Display the number of students in Course_ID 44.

 Use mysql

 Show databases

 Show tables
 CREATE TABLE Student
 INSERT INTO Student

 SELECT * FROM Student


a. Display the list of Students in Batch '2017-2020'.

b. Display the Enrolment No of 4th semester students.

c. Display the list of students of Batch 2019-2022 and Course_ID = 17.

d. Display the number of students in Course_ID = 44.

You might also like