You are on page 1of 14

DATABASE MANAGEMENT SYSTEM

(DCO-412)

Submitted to: Submitted by


Mr. Faiz Akram & Dr. Sunil Student Name: Shayan Ahsan
Assistant Professor Roll No.: 20DCS048
Semester: 4th

Computer Engineering Section


University Polytechnic
Faculty of Engineering & Technology
Jamia Millia Islamia, New Delhi-110025
PRACTICAL RECORD

PAPER CODE : DCO-412


Name of the Student :Shayan
Ahsan

University Roll No. : 20DCS048


Program: Diploma in Computer Engineering

PRACTICAL DETAILS
Practical Practical Name Date of Date of Marks/ Teacher’s
No. Performance Checking Grades Signature
1. Write in detail about the 17 February
CREATE command. Create a 2022
database for College using
the following Tables
Table Name: Faculty
Attributes: Faculty ID,
Faculty Name, Qualification,
Department ID
Table Name: Student
Attributes: Student ID,
Student Name, Branch,
Marks
Table Name: Department
Attributes: Department ID,
Department Name
2. Write in detail about the 17 February
INSERT command. Insert 2022
data into the created tables.
3. Write in detail about the 24 February
SELECT command. Query 2022
the created database using
the select command.
Describe the DISTINCT,
WHERE, and ORDER BY
clauses used with select
command and show their
usage.
4. Write in detail about the 26 March
following operators and 2022
show their usage on the
created database
(a). IN, NOT IN (b).
BETWEEN, NOT
BETWEEN
(c). LIMIT (d). IS NULL, IS
NOT NULL
(e). LIKE, NOT LIKE
5. 5. Write in detail about the 26March
JOIN command. Show its 2022
usage on the created database
using
different types of joins used
in MySQL i.e.
(a). CROSS JOIN (b).
INNER JOIN
(c). LEFT JOIN (d). RIGHT
JOIN
6. Write in detail about the SET 14 April 2022
operations including
UNION, MINUS, and
INTERSECT. Show their
usage on the created
database.
7. Write in detail about the 14 April 2022
AGGREGATE functions
including COUNT, SUM,
MAX, MIN, and AVERAGE.
Show their usage on the
created database.
8.
9.

10.
Practical No. 6: Write in detail about the SET operations including UNION, MINUS, and
INTERSECT. Show their usage on the created database.
The SQL Set operation is used to combine the two or more SQL SELECT statements.

Union Operation
The SQL Union operation is used to combine the result of two or more SQL SELECT queries.
In the union operation, all the number of data type and columns must be same in both the tables on which
UNION operation is being applied.
The union operation eliminates the duplicate rows from its result set.
Syntax
SELECT column_name FROM table1
UNION
SELECT column_name FROM table2;

Consider the two tables below:


STUDENTS
StudentID StudentName Branch Marks
1 Arif Computer Engineering 70
2 Faizan Civil Engineering 60
3 Shahbaz Electronics Engineering 80
4 Daud Electrical Engineering 65
5 Meraj Mechanical Engineering 70
6 Akram Mechanical Engineering 70
7 Arman Electrical Engineering 82
8 Shoeb Civil Engineering 90
9 MD Danish Science 80
10 Shahbaz Khan Commerce 75

TEACHER
TeacherName Branch Qualification
Faiz Akram Computer Engineering M. tech
Mohd Sadiq Computer Engineering P. hd
Md Khalid Electronics Engineering P. hd
Shahzad Ali Electrical Engineering P. hd
Mohammad Waseem Mechanical Engineering P. hd
Zillur Rehman Civil Engineering P. hd
Hafsa Nigar Electronics Engineering M. tech
Sadat Ali Mechanical Engineering P.hd
Syed Gulraze Physics P. hd
Raquib Alam Physical Chemistry P. hd

Union SQL query will be:


SELECT Branch FROM Students
UNION
SELECT Branch FROM Teacher;

MYSQL

Intersect
It is used to combine two SELECT statements. The Intersect operation returns the common rows
from both the SELECT statements.

In the Intersect operation, the number of datatype and columns must be the same. It has no
duplicates and it arranges the data in ascending order by default.

Syntax

SELECT column_name FROM table1 INTERSECT

SELECT column_name FROM table2;

Intersect is not a mysql function. It does not work in mysql if we run this query we get an error. So
simply we write below given query instead of above –

SELECT table 1. column_name FROM table 1 INNER JOIN table 2 USING (column_name);

Using the above First and Second table. Intersect query will be:

SELECT Students.Branch FROM Students INNER JOIN Teacher USING (Branch);

MYSQL CONSOLE:
Minus Operation
It combines the result of two SELECT statements. Minus operator is used to display the rows which are
present in the first query but absent in the second query.
It has no duplicates and data arranged in ascending order by default.
Syntax:
SELECT column_name FROM table1
MINUS
SELECT column_name FROM table2;

MySql does not recognise MINUS and INTERSECT, these are Oracle based operations. In MySql a user
can use NOT IN as MINUS. Syntax of minus in mysql is given below –
SELECT table1. column_name FROM table1
WHERE table1. column_name NOT IN
SELECT table2. column_name FROM table2;

Minus query will be:


SELECT Students. Branch FROM Students
WHERE Students. Branch NOT IN
(SELECT Teacher. Branch FROM Teacher);

MYSQL CONSOLE:
Practical No. 7: Write in detail about the AGGREGATE functions including COUNT, SUM, MAX,
MIN, and AVERAGE. Show their usage on the created database.

MySQL Aggregate Functions


MySQL's aggregate function is used to perform calculations on multiple values and return the result in a
single value like the average of all values, the sum of all values, and maximum & minimum value among
certain groups of values. We mostly use the aggregate functions with SELECT statements in the data query
languages.

Consider the table that is given below:


STUDENTS
StudentID StudentName Branch Marks
1 Arif Computer Engineering 70
2 Faizan Civil Engineering 60
3 Shahbaz Electronics Engineering 80
4 Daud Electrical Engineering 65
5 Meraj Mechanical Engineering 70
6 Akram Mechanical Engineering 70
7 Arman Electrical Engineering 82
8 Shoeb Civil Engineering 90
9 MD Danish Science 80
10 Shahbaz Khan Commerce 75

COUNT FUNCTION
The COUNT() function returns the number of rows that matches a specified criterion.
COUNT() Syntax
SELECT COUNT(column_name)
FROM table_name
WHERE condition;

Count query will be:


SELECT COUNT(Branch) FROM STUDENTS
WHERE Branch = ‘Mechanical Engineering’;
MYSQL CONSOLE:

Count another query will be:


SELECT Branch ,COUNT(*) FROM STUDENTS
GROUP BY Branch;

MYSQL CONSOLE:

SUM FUNCTION
The SUM() function returns the total sum of a numeric column.
SUM() Syntax
SELECT SUM(column_name)
FROM table_name
WHERE condition;
Sum query will be:
SELECT SUM(Marks) FROM Students;

MYSQL CONSOLE:

MAX FUNCTION
The MAX() function returns the largest value of the selected column.
MAX() Syntax
SELECT MAX(column_name)
FROM table_name
WHERE condition;

Max query will be:


SELECT MAX(Marks) FROM Students;

MYSQL CONSOLE:

MIN FUNCTION
The MIN() function returns the smallest value of the selected column.
MIN() Syntax
SELECT MIN(column_name)
FROM table_name
WHERE condition;

Min query will be:


SELECT MIN(Marks) FROM Students;

MYSQL CONSOLE:

AVERAGE FUNCTION
The AVG() function returns the average value of a numeric column.
AVG() Syntax
SELECT AVG(column_name)
FROM table_name
WHERE condition;

Average query will be:


SELECT AVG(Marks) FROM Students;

mysql> select avg( marks) f om s ude n s;

I avg( mar s) I
74.2000 I
1 ow in se (0.00 sec)

You might also like