Term 2 Material

Download as pdf or txt
Download as pdf or txt
You are on page 1of 99

AS PER THE NEW CBSE TERM-2 SYLLABUS

HIGHLIGHTED NOTES,
QUESTIONS AND ANSWERS
(SESSION 2021-22)

Chief Patron
SRI D P PATEL,
DEPUTY COMMISSIONER
KVS REGIONAL OFFICE RANCHI

Patron
SHRI D V RAMAKRISHNA,
ASSISTANT COMMISSIONER, KVS RO RANCHI

Subject Convenor
MR. DINESH KUMAR RAM,
PGT(CS), KENDRIYA VIDYALAYA
HINOO 1ST SHIFT, RANCHI

CONTENT TEAM & VETTED BY SUBJECT TEACHERS


Mr. R.N.P Sinha, PGT(CS) KV Hinoo 2nd Shift Ranchi
Mr. Ravi Prakash, PGT(CS) KV Namkum Ranchi

Cover Page Design and Content Compiled by:


Mr. Dinesh Kumar Ram, PGT(CS), KV Hinoo 1st Shift Ranchi

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 1


CONTENTS

SYLLABUS- Term-2 03-05

CHAPTER 01
MySQL Functions and Querying using SQL 06-13

CHAPTER 02
Aggregate Functions and Querying 14-27

CHAPTER 03
Question Bank ‘Database Query Using SQL’ 28-52

CHAPTER 04
Computer Networks 53-64

CHAPTER 05
Introduction to Internet and Web 65-76

CHAPTER 06
CBSE Sample Paper (Term-2)- 2021-22 77-87

CHAPTER 07
Practice Papers 88-98

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 2


Syllabus
CBSE Term II Class XII
Distribution of Theory Marks

Unit No. Unit Name Marks


2. Database Query using SQL 25
3. Introduction to Computer Networks 10
Total 35

Unit 2 Database Query usingSQL


 Math functions: POWER (), ROUND (), MOD ().
 Text functions: UCASE ()/UPPER (), LCASE ()/LOWER (), MID ()/SUBSTRING ()/SUBSTR( )
LENGTH (), LEFT (), RIGHT (), INSTR (), LTRIM (), RTRIM (), TRIM ().
 Date Functions: NOW (), DATE (), MONTH (), MONTHNAME (), YEAR (), DAY (), DAYNAME
(). Aggregate Functions: MAX (), MIN (), AVG (), SUM (), COUNT ();
using COUNT (*).
 Querying and manipulating data using Group by, Having, Order by.

Unit 3 Introduction to Computer Networks


 Introduction to networks, Types of network: LAN, MAN, WAN.
 Network Devices: modem, hub, switch, repeater, router, gateway.
 Network Topologies: Star, Bus, Tree, Mesh.
 Introduction to Internet, URL, WWW and its applications- Web, email, Chat, VoIP.
 Website: Introduction, difference between a website and webpage, static
dynamic web page, web server and hosting of a website.
 Web Browsers: Introduction, commonly used browsers, browser settings, add-ons
and plug-ins, cookies.

Distribution of Practical Marks


Topic Marks
SQL queries (pen and paper) 7
Practical File – 12 SQL Queries 2
Final Project Submission 3
Viva 3
Total 15

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 3


Suggested Practical List Data Management
1. Create a student table with the student id, name, and marks as attributes where the
student id is the primary key.
2. Insert the details of a new student in the above table.
3. Delete the details of a student in the above table.
4. Use the select command to get the details of the students with marks more than 80.
5. Find the min, max, sum, and average of the marks in a student marks table.
6. Find the total number of customers from each country in the table (customer ID,
customer Name, country) using group by.
7. Write a SQL query to order the (student ID, marks) table in descending order of the
marks.

Project Work
The aim of the class project is to create tangible and useful IT applications. The learner may

identify a real-world problem by exploring the environment. e.g. Students can visit shops/business
places, communities or other organizations in their localities and enquire about the functioning of
the organization, and how data are generated, stored, and managed.

The learner can take data stored in csv or database file and analyze using Python libraries and
generate appropriate charts to visualize. If an organization is maintaining data offline, then the

learner should create a database using MySQL and store the data in tables.

Data can be imported in Pandas for analysis and visualization. Learners can use Python libraries of
their choice to develop software for their school or any other social good. Learners should be
sensitized to avoid plagiarism and violation of copyright issues while working on projects. Teachers
should take necessary measures for this. Any resources (data, image etc.) used in the project

must be suitably referenced.

The project can be done individually or in groups of 2 to 3 students. The project should be started by
students at least 6 months before the submission deadline.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 4


CHAPTER-1 01
MySQL Functions and
Querying using SQL
What is a function?
A function is a predefined formula which takes one or more arguments as input then
process the arguments and returns an output.
MySQL function
A function is a set of predefined commands that performs specific operation and returns a
single value. The functions used in SQL can be categorised into two categories namely single
row or scalar functions and multiple row or group or aggregate functions.

Single Row Functions: These are also known as Scalar functions. Single row functions
are applied on a single value and return a single value.

Mathematical Functions: MySQL provides a number of functions used for performing


mathematical calculations on database. Mathematical functions are very important in SQL

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 5


to implement different mathematical concepts in queries. Some mathematical functions
are explained with examples as follows:

Function Description Example


MOD ( A,B) Return the remainder of A/B SELECT MOD(11,3) ; OUTPUT:- 2
SELECT MOD(10.5,3) ; OUTPUT:- 1.5

POWER ( A,B) Returns the value of A raised to the SELECT POWER(5,3) ; OUTPUT:- 125
or power B SELECT POW(2,-2) ; OUTPUT:- 0.25
POW(A,B) SELECT POWER(-2,3) ; OUTPUT:- -8
SELECT POWER(2.37,3.45) ; OUTPUT:-
19.6282….

ROUND (N,D ) Return number rounded to D place SELECT ROUND(1.58) ; OUTPUT:- 2


after decimal, If D is not specified,N is
rounded up to 0 digit of decimal and SELECT ROUND(-1.23) ; OUTPUT:- -1
the result is an Integer.
If the first digit after the decimal SELECT ROUND(1.298,0) ; OUTPUT:- 1
value is 5 or >5 then integer number
is increased by 1 SELECT ROUND(-5.898,0) ;OUTPUT:- -6
If D is +ve ,then N is rounded up to D
digits after the decimal by checking SELECT ROUND(3.79867,3) ; OUTPUT:-
D+1th digit,if it is 5or <5,then the 3.799
dthdigit is increased by 1 If D is -ve ,
then N is rounded up to D digits SELECT ROUND(23.298,-1) ; OUTPUT:-
before the decimal by checking Dth 20
digit, if it is 5 or >5 then d-1th digit is
increased by 1,all trailing dth digits SELECT ROUND(36567.78,-4) ;
are converted to 0 and the result is an OUTPUT:- 40000
integer value.

SIGN ( ) Return the sign of the given number SELECT SIGN(-10) ; OUTPUT:- -1
SELECT SIGN(10) ; OUTPUT:- 1

SQRT ( ) Return the non-negative square root SELECT SQRT(25) ; OUTPUT:- 5


of the given number
TRUNCATE( x, d) Truncates x to the specified number SELECT TRUNCATE(7.29, 0) ;
of d. If d is 0,it removes all the decimal OUTPUT:- 7
values and returns integer.
If d is +ve, Truncates x to d digits right SELECT TRUNCATE(27.59, 1) ;
to the decimal point. OUTPUT:- 27.5
If d is -ve, Truncates x to d digits left fo
the decimal point. SELECT TRUNCATE(389.23, -2) ;
OUTPUT:- 300
ABS (value ) Returns the absolute value of the SELECT ABS(-25) ; OUTPUT:- 25
given value. SELECT ABS(-234.67) ;
OUTPUT:- 234.67

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 6


String/Text Functions: The string/text functions of SQL are used to extract, change, format or
alter character strings. They accept a character string as an input and provides character string or
numeric values as an output. Some string/text functions are explained with example as follows :
Function Description Example
ASCII( ) Returns the ASCII code of the SELECT ASCII (‘A’ ) FROM DUAL; OUTPUT:- 65
character.
SELECT ASCII (‘1’ ) FROM DUAL; OUTPUT:- 49
SELECT ASCII (‘ABC’ ) FROM DUAL; OUTPUT:- 65
Remove spaces from beginning SELECT TRIM( ‘ APPLE ‘);
TRIM ( )
and ending OUTPUT:’APPLE’
Returns string after removing SELECT LTRIM( ‘ APPLE ‘); OUTPUT:’APPLE
LTRIM ()
left side of spaces. ’

Returns string after removing SELECT LTRIM( ‘ APPLE ‘);


RTRIM ()
right side of spaces. OUTPUT:’ APPLE’

It search one string in another SELECT INSTR (‘COMPUTER’,’PUT’) ;


INSTR( )
string and returns position, if OUTPUT: - 4
not found 0
SELECT INSTR (‘COMPUTER’,’PY’) ;
OUTPUT: - 0
Returns number of Characters SELECT LENGTH (‘COMPUTER’) ;
LENGTH ( )
in the string.
OUTPUT: - 8
Returns N characters of String S SELECT LEFT(‘COMPUTER’,3) ;
LEFT (S,N)
from beginning
OUTPUT:- COM
Returns N characters of String S SELECT RIGHT(‘COMPUTER’,3) ;
RIGHT(S,N)
from ending
OUTPUT:- TER
Returns the substring as SELECT SUBSTR(‘COMPUTER’,3,4) ;
SUBSTR ( )
specified
OUTPUT:- MPUT
Returns concatenated String SELECT CONCAT(‘COM’,’PUTER’) ;
CONCATE ()
OUTPUT:- COMPUTER
Converts string into lowercase. SELECT LOWER(‘COMPUTER’) ; OUTPUT:-
LOWER() /
LCASE() computer
Converts string into uppercase. SELECT UPPER(‘COMPUTER’) ;
UPPER() /
UCASE() OUTPUT:- COMPUTER

Replace all occurrences of the SELECT REPLACE (‘INFO


REPLACE()
second string in the first string COMPUTER’,’INFO’,’LATEST’) ;
with the third string. OUTPUT:- LATEST COMPUTER
Return reverse of the given SELECT REVERSE(‘COMPUTER’) ;
REVERSE()
string.
OUTPUT:- RETUPMOC
Returns a given string for a SELECT REPEAT(‘COM’,3) ;
REPEAT ()
specified number of times.
OUTPUT:- COMCOMCOM

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 7


Date/Time Functions: MySQL stores date in date/time format, representing the century,
month, year, day and hours. The date and time functions are used to perform operations on the
date/time data stored in the database. The default date format is YYYY-MM-DD in MySQL. Some
date/time functions are explained with examples as follows:
Function Description Example
CURDATE( ) Returns the current Date SELECT CURDATE( ) ; OUTPUT:-
14/06/2021

DATE( ) Returns the Date part only SELECT DATE( ‘01/07/2020’) ;


OUTPUT:- 01

MONTH ( ) Returns the Month part only SELECT MONTH (‘01/07/2020’ )


OUTPUT: - 07
YEAR ( ) Returns the Year part only SELECT YEAR (‘01/07/2020’ )
OUTPUT: - 2020
DAYNAME ( ) Returns the name of the week day SELECT DAYNAME (‘01/07/2020’ )
OUTPUT: - WEDNESDAY
MONTHNAME () Returns the name of the month. SELECT MONTHNAME (‘01/07/2020’
) OUTPUT: - JULY
DAYOFMONTH( ) Returns the day of the month(1-31) SELECT DAYOFMONTH
(‘01/07/2020’ ) OUTPUT: - 01
DAYOFWEEK ( ) Returns the weekday index of the SELECT DAYOFWEEK (‘01/07/2020’ )
date. OUTPUT: - 04
DAYOFYEAR ( ) Returns the day of the year(1-366). SELECT DAYOFYEAR (‘01/07/2020’ )
OUTPUT: - 183
NOW ( ) Returns both current date & time at SELECT NOW ( );
which the function execute.
SYSDATE ( ) Returns the current date & time. SELECT NOW ( ) , SLEEP(2), NOW( );
OUTPUT: 01/07/2020 04:20:32
01/07/2020 04:20:32
SELECT SYSDATE( ), SLEEP ( 2 ),
SYSDATE( );
OUTPUT: 01/07/2020 04:20:32
01/07/2020 04:20:34

Difference Between NOW() and SYSDATE() : NOW() function return the date and time at which
function was executed even if we execute multiple NOW() function with select. whereas SYSDATE()
will always return date and time at which each SYSDATE() function started execution.

For example:
mysql> Select now(), sleep(2), now();

Output: 2018-12-04 10:26:20, 0, 2018-12-04 10:26:20

mysql> Select sysdate(), sleep(2), sysdate();

Output: 2018-12-04 10:27:08, 0, 2018-12-04 10:27:10

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 8


Chapter Practice:
A. Question based on String Function:
Answer the question 1 to 12 by Considering the following table
Students
StudentID StudentName Marks
1 Sanjay 64
2 Varun 72
3 Akash 45
4 Rohit 86
5 Anjali 92

Q1. Write a query to count the number of students from the Students table.
Ans: SELECT COUNT(StudentID) FROM Students;
Q.2 Write a query to count the number of students scoring marks > 75 from the Students table.
Ans: SELECT COUNT(StudentID) FROM Students WHERE Marks >75;
Q3. This function is used to return the average value of a numeric column.
Ans: SELECT AVG(ColumnName) FROM TableName;
Q4. Write a query to calculate the average marks of all students from the Students table.
Ans: SELECT AVG(Marks) FROM Students;
Q5. Write a query to retrieve the minimum marks out of all students from the Students table.
Ans: SELECT MIN(Marks) FROM Students;
Q6. Write a query to retrieve the maximum marks out of all students from the Students table.
Ans: SELECT MAX(Marks) FROM Students;
Q7. Write a query to retrieve the marks of the first student.
Ans: SELECT FIRST(Marks) FROM Students;
Q8. Write a query to retrieve the marks of the last student.
Ans: SELECT LAST(Marks) FROM Students;
Q9. Write a query to retrieve the names of all students in lowercase.
Ans: SELECT LCASE(StudentName) FROM Students;
Output:
sanjay
varun
akash
rohit
anjali
Q10. Write a query to retrieve the names of all students in lowercase.
Ans: SELECT UCASE(StudentName) FROM Students;
Output:
SANJAY
VARUN
AKASH
ROHIT
ANJALI
Q11. Write a query to extract the length of the student name “Sanjay”.
Ans: SELECT LENGTH(“Sanjay”) AS StudentNameLen;
Output: 6

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 9


Q12. Write a query to extract substrings from the StudentName column.
Ans: SELECT MID(StudentName, 2, 3) FROM Students;
Output:
anj
aru
kas
ohi
nja

B. Question based on String Function:


Answer the question 1 to 12 by Considering the following table
Marks
StudentID StudentName Marks
1 Sanjay 90.76
2 Varun 80.45
3 Akash 54.32
4 Rohit 72.89
5 Anjali 67.66

Q1. Write a query to round the marks to the integer value.


Ans: SELECT ROUND(Marks) FROM Students;
Output:
91
80
54
73
68
Q2.Write a query to retrieve the current date and time.
Ans: SELECT NOW();
Output: NOW()
2019-10-14 09:16:36

Q3. Write a query to display the numbers “123456789” in the format “###-###-###”
Ans: SELECT FORMAT(123456789, “###-###-###”);
Output: 123-456-789

Short Answer Type Questions:

Q1. Which type of MySQL function accepts only numeric values? Give the name of some functions
of that type.
Ans. Mathematical functions accept only numeric values and return the value of same type. These
functions are used to perform mathematical operations on the database data. Some mathematical
functions are OW()/POWER(), ROUND(), etc.
Q2. Which SQL function is used to remove leading and trailing spaces from a character expression X,
where X = ‘LEARNING ###MYSQL####’ (# denotes a blank space) and also give the output of X.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 10


Ans. TRIM function is used to remove all leading and trailing spaces from the given character
expression.
Syntax TRIM([{BOTH|LEADING|TRAILING} [remstr] FROM] str/column_name)
e.g. mysql> SELECT TRIM(' LEARNING###MYSQL####');
Output LEARNING###MYSQL
Spaces between ‘LEARNING’ and ‘MYSQL’ cannot be removed.
Q 3. Write the output of following MySQL queries:
(i) SELECT ROUND(6.5675,2);
(ii) SELECT TRUNCATE(5.3456,2);
(iii) SELECT DAYOFMONTH(curdate());
(iv) SELECT MID('PRE_BOARDCLASS 12',4,6);
Ans. (i)

(ii)

(iii) If curdate is 05/12/2017, then output is 5.


(iv)

Q4. Predict the output of the following queries:


(i) mysql>SELECT POWER(3,2);
(ii) mysql>SELECT DATE('2009-01-21 02:01:04');
Ans:

Q5. Write the name of the functions to perform the following operations:
(i) To display the day like “Monday”, “Tuesday”, from the date when India got independence.
(ii) To display the specified number of characters from a particular position of the given string.
(iii) To display the name of the month in which you were born.
(iv) To display your name in capital letters.
Ans. (i) DAYNAME( )
(ii) MID( ) or SUBSTR( ) or SUBSTRING( )
(iii) MONTHNAME( )
(iv) UPPER( ) or UCASE( )

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 11


Q6. Wrtie any four differences between single-row functions and multiple-row functions.
Ans:

Q7. What is the differences between the string function and numeric function ?
Ans. Differences between string and numeric functions are given below:
String Function Numeric Function

Accepts text input Accepts only numeric values


Returns both numeric and string Returns only numeric values. String functions
values. include

String functions include Numeric functions include


ASCII(), CHAR(), LEFT(),etc. POW( ), ROUND ( ), TRUNCATE( ), etc.

Q8. Mention the type of the functions given below with their purpose.
(i) TRUNCATE( )
(ii) DAYOFMONTH( )
(iii) LEFT( )
Ans. (i) TRUNCATE( ) It is a mathematical function and returns a number truncated up to specified
number of digits.
(ii) DAYOFMONTH( ) It is a Date/Time function and returns the day of month for the specified date.
(iii) LEFT( ) It is a string function and returns the leftmost number of characters as specified.

Q9. Give the output of following commands :


(i) mysql>SELECT LEFT ('Swati',4);
(ii) mysql>SELECT RTRIM ('!!!!!Study is important!!!!!'); where, !!!!! denotes blank spaces.
(iii) mysql>SELECT ROUND(3234.343,1);
Ans:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 12


Q10. Write the output of the following SQL queries:
(i) SELECT SUBSTR(TRIM(' INDIA Is Great ',3,6) ;
(ii) SELECT ROUND(654.67152) + ROUND(152.4146,2) ;
(iii) SELECT INSTR('MOBILE PHONE','E') ;
(iv) SELECT DAYOFMONTH('2019-11-22');
Ans:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 13


CHAPTER-2 01
Aggregate Functions
Aggregate functions are also called multiple row functions. These functions work on a
set of records as a whole, and return a single value for each column of the records
on which the function is applied.
Aggregate Functions is used to perform calculation on group of rows and return the
calculated summary like sum of salary , average of salary.

1. AVG() 2. COUNT() 3.MAX()


4 .MIN() 5. SUM( )

1. 1. AVG() Function: The AVG() function returns the average value of a numeric
column.
Syntax: SELECT AVG(column_name) FROM table_name

SQL AVG() Example: We have the following "Orders" table:


O_Id OrderDate OrderPrice Customer
1 2018/11/12 1000 Vivek Kumar
2 2021/10/23 1600 Nitesh Sharma
3 2020/09/02 700 Vivek Kumar
4 2019/09/03 300 Vivek Kumar
5 2020/08/30 2000 Samarjeet Gupta
6 2020/10/04 100 Nitesh Sharma

Now we want to find the average value of the "OrderPrice" fields.

We use the following SQL statement:


SELECT AVG(OrderPrice) AS OrderAverage FROM Orders

The result-set will look like this:


OrderAverage
950

Now we want to find the customers that have an OrderPrice value higher than the average
OrderPrice value.

We use the following SQL statement:

SELECT Customer FROM Orders


WHERE OrderPrice>(SELECT AVG(OrderPrice) FROM Orders)

The result-set will look like this:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 14


Customer
Vivek Kumar
Nitesh Sharma
Samarjeet Gupta

2. COUNT( ) Function:

The COUNT() function returns the number of rows that matches a specified criteria.

The COUNT(column_name) function returns the number of values (NULL values will not be
counted) of the specified column:

SELECT COUNT(column_name) FROM table_name

The COUNT(*) function returns the number of records in a table:

SELECT COUNT(*) FROM table_name

The COUNT(DISTINCT column_name) function returns the number of distinct values of the
specified column:

SELECT COUNT(DISTINCT column_name) FROM table_name

COUNT(column_name) Example

We have the following "Orders" table:

O_Id OrderDate OrderPrice Customer


1 2018/11/12 1000 Vivek Kumar
2 2021/10/23 1600 Nitesh Sharma
3 2020/09/02 700 Vivek Kumar
4 2019/09/03 300 Vivek Kumar
5 2020/08/30 2000 Samarjeet Gupta
6 2020/10/04 100 Nitesh Sharma

Now we want to count the number of orders from "Customer Nitesh Sharma".

We use the following SQL statement:

SELECT COUNT(Customer) AS CustomerNitesh Sharma FROM Orders


WHERE Customer='Nitesh Sharma'

The result of the SQL statement above will be 2, because the customer Nitesh Sharma has
made 2 orders in total:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 15


Customer Nitesh Sharma

Example: If we omit the WHERE clause, like this:


SELECT COUNT(*) AS NumberOfOrders FROM Orders

The result-set will look like this:

NumberOfOrders

which is the total number of rows in the table.

COUNT(DISTINCT column_name) Example:

Now we want to count the number of unique customers in the "Orders" table.

We use the following SQL statement:

SELECT COUNT(DISTINCT Customer) AS NumberOfCustomers FROM Orders

The result-set will look like this:

NumberOfCustomers

which is the number of unique customers (Vivek Kumar, Nitesh Sharma, and Samarjeet
Gupta) in the "Orders" table.

3. The MAX() Function


The MAX() function returns the largest value of the selected column.

Syntax: SELECT MAX(column_name) FROM table_name

Example: We have the following "Orders" table:


O_Id OrderDate OrderPrice Customer
1 2018/11/12 1000 Vivek Kumar
2 2021/10/23 1600 Nitesh Sharma
3 2020/09/02 700 Vivek Kumar
4 2019/09/03 300 Vivek Kumar
5 2020/08/30 2000 Samarjeet Gupta
6 2020/10/04 100 Nitesh Sharma

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 16


Now we want to find the largest value of the "OrderPrice" column.

We use the following SQL statement:


SELECT MAX(OrderPrice) AS LargestOrderPrice FROM Orders

The result-set will look like this:


LargestOrderPrice
2000

4. The MIN() Function

The MIN() function returns the smallest value of the selected column.
Syntax: SELECT MIN(column_name) FROM table_name
Example: We have the following "Orders" table:
O_Id OrderDate OrderPrice Customer
1 2018/11/12 1000 Vivek Kumar
2 2021/10/23 1600 Nitesh Sharma
3 2020/09/02 700 Vivek Kumar
4 2019/09/03 300 Vivek Kumar
5 2020/08/30 2000 Samarjeet Gupta
6 2020/10/04 100 Nitesh Sharma

Now we want to find the smallest value of the "OrderPrice" column.

We use the following SQL statement:


SELECT MIN(OrderPrice) AS SmallestOrderPrice FROM Orders

The result-set will look like this:


SmallestOrderPrice
100

5. The SUM() Function

The SUM() function returns the total sum of a numeric column.


Syntax: SELECT SUM(column_name) FROM table_name
Example: We have the following "Orders" table:
O_Id OrderDate OrderPrice Customer
1 2018/11/12 1000 Vivek Kumar
2 2021/10/23 1600 Nitesh Sharma
3 2020/09/02 700 Vivek Kumar
4 2019/09/03 300 Vivek Kumar
5 2020/08/30 2000 Samarjeet Gupta
6 2020/10/04 100 Nitesh Sharma

Now we want to find the sum of all "OrderPrice" fields".

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 17


We use the following SQL statement:
SELECT SUM(OrderPrice) AS OrderTotal FROM Orders

The result-set will look like this:


OrderTotal
5700

The GROUP BY Statement

The GROUP BY statement is used in conjunction with the aggregate functions to group the
result-set by one or more columns.
Syntax:
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name

Example: We have the following "Orders" table:


O_Id OrderDate OrderPrice Customer
1 2018/11/12 1000 Vivek Kumar
2 2021/10/23 1600 Nitesh Sharma
3 2020/09/02 700 Vivek Kumar
4 2019/09/03 300 Vivek Kumar
5 2020/08/30 2000 Samarjeet Gupta
6 2020/10/04 100 Nitesh Sharma

Now we want to find the total sum (total order) of each customer.

We will have to use the GROUP BY statement to group the customers.

We use the following SQL statement:


SELECT Customer,SUM(OrderPrice) FROM Orders
GROUP BY Customer

The result-set will look like this:


Customer SUM(OrderPrice)
Vivek Kumar 2000
Nitesh Sharma 1700
Samarjeet Gupta 2000

Let's see what happens if we omit the GROUP BY statement:


SELECT Customer,SUM(OrderPrice) FROM Orders

The result-set will look like this:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 18


Customer SUM(OrderPrice)
Vivek Kumar 5700
Nitesh Sharma 5700
Vivek Kumar 5700
Vivek Kumar 5700
Samarjeet Gupta 5700
Nitesh Sharma 5700

The result-set above is not what we wanted.

Explanation of why the above SELECT statement cannot be used: The SELECT statement
above has two columns specified (Customer and SUM(OrderPrice). The "SUM(OrderPrice)"
returns a single value (that is the total sum of the "OrderPrice" column), while "Customer"
returns 6 values (one value for each row in the "Orders" table). This will therefore not give
us the correct result. However, you have seen that the GROUP BY statement solves this
problem.

GROUP BY More Than One Column

We can also use the GROUP BY statement on more than one column, like this:
SELECT Customer, OrderDate, SUM(OrderPrice) FROM Orders
GROUP BY Customer,OrderDate

The HAVING Clause

The HAVING clause was added to MySQL because the WHERE keyword could not be used
with aggregate functions.
Syntax:
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value

Example: We have the following "Orders" table:


O_Id OrderDate OrderPrice Customer
1 2018/11/12 1000 Vivek Kumar
2 2021/10/23 1600 Nitesh Sharma
3 2020/09/02 700 Vivek Kumar
4 2019/09/03 300 Vivek Kumar
5 2020/08/30 2000 Samarjeet Gupta
6 2020/10/04 100 Nitesh Sharma

Now we want to find if any of the customers have a total order of less than 2000.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 19


We use the following SQL statement:
SELECT Customer,SUM(OrderPrice) FROM Orders
GROUP BY Customer
HAVING SUM(OrderPrice)<2000

The result-set will look like this:


Customer SUM(OrderPrice)
Nitesh Sharma 1700

Now we want to find if the customers "Vivek Kumar" or "Samarjeet Gupta" have a total
order of more than 1500.

We add an ordinary WHERE clause to the SQL statement:


SELECT Customer, SUM(OrderPrice) FROM Orders
WHERE Customer='Vivek Kumar' OR Customer='Samarjeet Gupta'
GROUP BY Customer
HAVING SUM(OrderPrice)>1500

The result-set will look like this:


Customer SUM(OrderPrice)
Vivek Kumar 2000
Samarjeet Gupta 2000

Chapter Practice:
Multiple Choice Questions
1. Which of the following is not an aggregate function?
(a)AVG() (b) ADD()
(c) MAX() (d) COUNT()
Ans. (b) There is no aggregate function named ADD() but SUM() is an aggregate function which
performs mathematical sum of multiple rows having numerical values.
2. Which aggregate function returns the count of all rows in a specified table?
(a)SUM() (b) DISTINCT()
(c) COUNT() (d) None of these
Ans. (c) COUNT() function returns the total number of values or rows of the specified field or
column.
3. In which function, NULL values are excluded from the result returned?
(a) SUM() (b) MAX()
(c) MIN() (d) All of these
Ans. (d) NULL values are excluded from the result returned by all the aggregate functions.
4. The AVG() function in MySQL is an example of
(a) Math function (b) Text function

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 20


(c) Date function (d) Aggregate function
Ans. (d) The AVG() function returns the average value from a column or multiple-rows.
So, the AVG ( ) function in MySQL is an example of aggregate function.
5. Which of the following function count all the values except NULL?
(a) COUNT(*) (b) COUNT(column_name)
(c) COUNT(NOT NULL) (d) COUNT(NULL)
Ans. (a) All aggregate functions exclude NULL values while performing the operation and
COUNT(*) is an aggregate function.
6. What is the meaning of “GROUP BY” clause in MySQL?
(a) Group data by column values
(b) Group data by row values
(c) Group data by column and row values
(d) None of the mentioned
Ans. (a) Through GROUP BY clause we can create groups from a column of data in a table.
7. Which clause is similar to “HAVING” clause in MySQL?
(a)SELECT (b) WHERE
(c) FROM (d) None of the mentioned
Ans. (b) HAVING clause will act exactly same as WHERE clause.
i.e. filtering the rows based on certain conditions.
8. Which clause is used with an “aggregate functions”?
(b)GROUP BY (b) SELECT
(c) WHERE (d) Both (a) and (c)
Ans. (a) “GROUP BY” is used with an aggregate functions.
9. What is the significance of the statement “GROUP BY d.name” in the following MySQL
statement? SELECT name, COUNT (emp_id), emp_no
FROM department

GROUP BY name;

(c) Counting of the field “name” on the table “department”


(d) Aggregation of the field “name” of table “department”
(e) Sorting of the field “name”
(f) None of the mentioned
Ans. (b) “GROUP BY” clause is used for aggregation of field. Above statement will find the
aggregation of the field “name” of table “department”.
10. What is the significance of the statement “HAVING COUNT (emp_id)>2” in the
following MySQL statement?
SELECT name, COUNT (emp_id),emp_no FROM department

GROUP BY name HAVING COUNT (emp_id)>2;

(g) Filter out all rows whose total emp_id below 2


(h) Selecting those rows whose total emp_id>2
(i) Both (a) and (b)
(j) None of the mentioned
Ans. (c) “HAVING” clause are worked similar as “WHERE” clause i.e. filtering the rows based
on certain conditions. GROUP BY command places conditions in the query using

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 21


HAVING clause. So, all the groups having employee count greater than 2 will be displayed.
11. What is the significance of “ORDER BY” in the following MySQL statement?
SELECT emp_id, fname, lname FROM person

ORDER BY emp_id;

(a) Data of emp_id will be sorted


(b) Data of emp_id will be sorted in descending order
(c) Data of emp_id will be sorted in ascending order
(d) All of the mentioned
Ans. (c) Sorting in ascending or descending order depends on keyword “DESC” and “ASC”. The
default order is ascending.
12. What will be the order of sorting in the following MySQL statement?
SELECT emp_id, emp_name FROM person

ORDER BY emp_id, emp_name;

(a) Sorting {emp_id, emp_name}


(b) Sorting {emp_name, emp_id}
(c) Sorting {emp_id} but not emp_name
(d) None of the mentioned
Ans. (a) In the query, first “emp_id” will be sorted then emp_name with respect to
emp_id.
13. Which of the following is not a valid SQL statement?
(a) SELECT MIN(pub_date) FROM books GROUP BY category HAVING pub_id = 4;
(b) SELECT MIN(pub_date) FROM books WHERE category = 'COOKING';
(c) SELECT COUNT(*) FROM orders WHERE customer#= 1005;
(d) SELECT MAX(COUNT(customer#)) FROM orders GROUP BY customer#;
Ans. (a) HAVING clause is wrongly applied on attribute “pub_id” rather than attribute “category”.
14. If emp_id contain the following set {9, 7, 6, 4, 3, 1, 2}, what will be the output on execution of
the following MySQL statement?
SELECT emp_id

FROM person ORDER BY emp_id;

(a) {1, 2, 3, 4, 6, 7, 9} (b) {2, 1, 4, 3, 7, 9, 6}


(c) {9, 7, 6, 4, 3, 1, 2} (d) None of the mentioned
Ans. (a) “ORDER BY” clause sort the emp_id in the result set in ascending order and in absence of
keyword ASC or DESC in the ORDER BY clause the default order is ascending.
15. Find odd one out?
(a) GROUP BY (b) DESC (c) ASC (d) ORDER BY
Ans. (a) “ORDER BY”, “DESC”, “ASC” are related to sorting whereas “GROUP BY” is not
related to sorting.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 22


Case Based MCQs
Direction Read the case and answer the following questions.

16. A School in Delhi uses database management system to store student details. The
school maintains a database 'school_record' under which there are two tables.
Student Table Maintains general details about every student enrolled in school.

StuLibrary Table To store details of issued books. BookID is the unique identification
number issued to each book. Minimum issue duration of a book is one day. [CBSE
Question Bank 2021]
Student
Field Type
StuLibrary
StuID numeric Field Type
StuName varchar(20) BookID numbric
StuAddress varchar(50) StuID numbric
StuFatherNam varchar(20) Issued_d Date
e ate
StuContact numeric Return_d Date
StuAadhar numeric ate
varchar(5)
StuSection varchar(1)

(i) Identify the SQL query which displays the data of StuLibrary table in ascending order
of student ID.
I. SELECT * FROM StuLibrary ORDER BY BookID;
II. SELECT * FROM StuLibrary ORDER BY StuID;
III. SELECT * FROM StuLibrary ORDER BY StuID ASC;
IV. SELECT * FROM StuLibrary ORDER BY StuID DESC;
Choose the correct option, which displays the desired data.

(a) Both I and IV (b) Both I and II


(c) Both III and IV (d) Both II and III
Ans. (d) Since the default order of sorting is ASC or ascending, therefore if it is not
mentioned in the query the query will take the default order.
(ii) The primary key for StuLibrary table is/are …….
(a) BookID (b) BookID,StuID
(c) BookID,Issued_date (d) Issued_date
Ans. (a) Because BookID will have unique and NOT NULL values.
(iii) Which of the following SQL query will display dates on which number of issued books
is greater than 5?
(a) SELECT Issued_date FROM StuLibrary GROUP BY Issued_date WHERE COUNT(*)>5;
(b) SELECT Issued_date FROM StuLibrary GROUPBY Return_date HAVING COUNT(*)>5;
(c) SELECT Issued_date FROM StuLibrary GROUP BY Issued_date HAVING
COUNT(*)>5;
(d) SELECT Issued_date FROM StuLibrary GROUP BY Return_date WHERE COUNT(*)>5;
Ans. (c) SELECT Issued_date FROM StuLibrary GROUPBY Issued_date HAVING COUNT(*)>5;

17. Table: Book_Information Table: Sales

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 23


Column Name Column Name
Book_ID Store_ID
Book_Title Sales_Date
Price Sales_Amount

(i) Which SQL statement allows you to find the highest price from the table
Book_Information?
(a) SELECT Book_ID,Book_Title,MAX(Price) FROM Book_Information;
(b) SELECT MAX(Price) FROM Book_Information;
(c) SELECT MAXIMUM(Price) FROM Book_Information;
(d) SELECT Price FROM Book_Information ORDER BY Price DESC ;
Ans. (b) SELECT MAX(Price) FROM Book_Information;
(ii) Which SQL statement allows you to find sales amount for each store?
(a) SELECT Store_ID, SUM(Sales_Amount) FROM Sales;
(b) SELECT Store_ID, SUM(Sales_Amount) FROM Sales ORDER BY Store_ID;
(c) SELECT Store_ID, SUM(Sales_Amount) FROM Sales GROUP BY Store_ID;
(d) SELECT Store_ID, SUM(Sales_Amount) FROM Sales HAVING UNIQUE Store_ID;
Ans. (c) SELECT Store_ID, SUM(Sales_Amount) FROMSales GROUP BY Store_ID;
(iii) Which SQL statement lets you to list all store name whose total sales amount is over 5000 ?
(a) SELECT Store_ID, SUM(Sales_Amount) FROM Sales GROUP BY Store_ID HAVING
SUM(Sales_Amount) > 5000;
(b) SELECT Store_ID, SUM(Sales_Amount) FROM Sales GROUP BY Store_ID HAVING
Sales_Amount > 5000;
(c) SELECT Store_ID, SUM(Sales_Amount) FROM Sales WHERE SUM(Sales_Amount) > 5000
GROUP BY Store_ID;
(d) SELECT Store_ID, SUM(Sales_Amount) FROM Sales WHERE Sales_Amount > 5000
GROUP BY Store_ID;
Ans. (a) SELECT Store_ID, SUM(Sales_Amount) FROMSales GROUP BY Store_ID HAVING
SUM(Sales_Amount) > 5000;
(iv) Which SQL statement lets you find the total number of stores in the SALES table?
(a) SELECT COUNT(Store_ID) FROM Sales;
(b) SELECT COUNT(DISTINCT Store_ID) FROM Sales;
(c) SELECT DISTINCT Store_ID FROM Sales;
(d) SELECT COUNT(Store_ID) FROM Sales GROUP BY Store_ID;
Ans. (d) SELECT COUNT(Store_ID) FROM Sales GROUP BY Store_ID;
(v) Which SQL statement allows you to find the total sales amount for Store_ID 25 and the
total sales amount for Store_ID 45?
(e) SELECT Store_ID, SUM(Sales_Amount) FROM Sales WHERE Store_ID IN ( 25,
45) GROUP BY Store_ID;
(f) SELECT Store_ID, SUM(Sales_Amount) FROM Sales GROUP BY Store_ID
HAVING Store_ID IN ( 25, 45);
(g) SELECT Store_ID, SUM(Sales_Amount) FROM Sales WHERE Store_ID IN (25,45);
(h) SELECT Store_ID, SUM(Sales_Amount) FROM Sales WHERE Store_ID = 25 AND
Store_ID =45 GROUP BY Store_ID;
Ans. (b) SELECT Store_ID, SUM(Sales_Amount) FROM Sales GROUP BY Store_ID
HAVING Store_ID IN ( 25, 45);

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 24


Subjective Questions

Short Answer Type Questions


1. What are the aggregate functions in SQL?
Ans. Aggregate function is a function where the values of multiple-rows are grouped
together as input on certain criteria to form a single value of more significant
meaning. Some aggregate functions used in SQL are
SUM ( ), AVG( ), MIN(), etc.
2. What is the purpose of GROUP BY clause in MySQL? How is it different from ORDER
BY clause?
Ans. The GROUP BY clause can be used to combine all those records that have identical
value in a particular field or a group of fields. Whereas, ORDER BY clause is used to
display the records either in ascending or descending order based on a particular
field. For ascending order ASC is used and for descending order, DESC is used. The
default order is ascending order.

3. Shanya Khanna is using a table EMPLOYEE. It has the following columns:


Admno, Name, Agg, Stream [column Agg contains Aggregate marks]

She wants to display highest Agg obtained in each Stream.

She wrote the following statement:

SELECT Stream, MAX(Agg) FROM EMPLOYEE;

But she did not get the desired result. Rewrite the above query with necessary changes to help
her get the desired output.

Ans. SELECT Stream, MAX(Agg)

FROM EMPLOYEE

GROUP BY Stream;

4. What is the differences between HAVING clause and Group By clause?


Ans

S.No. Having Clause Group By Clause


1. It is used for applying some extra condition to The group by clause is used to group
the query. the data according to particular
column or row.
2. Having can be used without group by clause, in group by can be used without having
aggregate function, in that case it behaves like clause with the select statement.
where clause.
3. The having clause can contain aggregate It cannot contain aggregate functions.
functions.
4. It restrict the query output by using some It groups the output on basis of some
conditions rows or columns.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 25


5. What is the difference between WHERE clause and HAVING clause?

Ans: A HAVING clause is like a WHERE clause, but applies only to groups as a whole (that is, to the
rows in the result set representing groups), whereas the WHERE clause applies to individual
rows. A query can contain both a WHERE clause and a HAVING clause.

6. Gopi Krishna is using a table Employee. It has the following columns :


Code, Name, Salary, Dept_code

He wants to display maximum salary department wise. He wrote the following command :

SELECT Deptcode, Max(Salary) FROM Employee;

But he did not get the desired result.

Rewrite the above query with necessary changes to help him get the desired output.

Ans. SELECT Deptcode, Max(Salary) FROM Employee

GROUP BY Deptcode;

7. Write a query that counts the number of doctors registering patients for each day. (If a
doctor has more than one patient on a given day, he or she should be counted only once .)
P_ID ProductName Manufact Price
ure
TP01 TALCOM POWDER LAK 40
FW05 FACE WASH ABC 45
BS01 BATH SOAP ABC 55
SH06 SHAMPOO XYZ 120
FW12 FACE WASH XYZ 95
Ans. SELECT ord_date, COUNT (DISTINCT doctor_code) FROM Patients

GROUP BY ord_date;

8. Consider the table DOCTOR given below. Write commands in SQL for (i) to (ii) and
output for (iii) to (v).
Table : DOCTOR
ID DOCName Department DOJ Gender Salary
1 Amit Kumar Orthopaedics 1993-02-12 M 35000
2 Anita Hans Paediatrics 1998-10-16 F 30000
3 Sunita Maini Gynaecology 1991-08-23 F 40000
4 Joe Thomas Surgery 1994-10-20 M 55000
5 Gurpreet Paediatrics 1999-11-24 F 52000
6 Anandini Oncology 1994-03-16 F 31000
(i) Display the names and salaries of doctors in descending order of salaries.
(ii) Display names of each department along with total salary being given to doctors of
that department.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 26


(iii) SELECT SUM(Salary) FROM DOCTOR WHERE
Department==‘Surgery’;
(iv) SELECT Department, COUNT(*) FROM DOCTOR GROUP BY
Department;
(v) SELECT DOCName FROM DOCTOR WHERE Department LIKE
‘%gery%’;
Ans. (i) SELECT DOCName, Salary FROM DOCTOR ORDER BY Salary DESC;

(ii) SELECT Department, SUM(Salary) FROM DOCTOR GROUP BY Department;

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 27


CHAPTER-3
Question Bank
Database Query using SQL

[1 marks question]
1) The avg( ) function in MySQL is an example of ………………….
(i) Math Function
(ii) Text Function
(iii) Date Function
(iv) Aggregate Function
Ans:- (v) Aggregate Function
2) The …………. Command can be used to make changes in the rows of table in SQL.
Ans:- UPDATE
3) The SQL Command that will display the current time and date.
Ans :- Select now();
4) The mid()function in MySql is an example of .
a. Math function
b. Text function
c. Date Function
d. Aggregate Function

Ans:- b. Text Function


5) The function is used in SQL to find one string into another.
Ans:- Instr( )
6) MID () and SUBSTR () function in SQL serves the same purpose. (Yes/No)
Ans:- Yes
7) Write the output for the following SQL command:
Select round(15.193 , -1);
Ans:- 10
8) Write a SQL query to display date after 10 days of current date on your system.
Ans:- Select curdate()+10;
1 mark for correct SQL command
9) Write the output for the following sql command:
Select SUBSTR(‘ABCDEFG’, -5 ,3)
Ans:- UBS
10) Which keyword is used to arrange the result of order by clause in descending order?
a. DSEC
b. DES
c. DESCE
d. DESNO
Ans:- a. DESC
11) The clause that is used to arrange the result of SQL command into groups

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 28


a.Order by
b.Group in
c.Groups by
d.Group by
Ans :- d.Group By
12) Find the Output of SQL command :
select concat (concat (‘Inform’, ‘atics’),‘Practices’);
a. Informatics Practices
b. Informatic Practices
c. Inform practices
d. Inform atics practices
Ans :- a. InformaticsPractices
13) Write the output of the following SQL command.
select round (19.88,1);
a. 19.88 b. 19.8 c. 19.9 d. 20.0
Ans:- c. 19.9
14) The now() function in MySql is an example of .
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- c. Date Function
15) The………….command can be used to makes changes in the structure of a table in SQL.
Ans:- ALTER
16) Write the SQL command that will display the time and date at which the command got
executed.
Ans :- Select sysdate();
17) Write the output of the following SQL command.
select round(15.872,1);
a. 15.87
b.15.9
c.15.8
d.16

Ans:- b. 15.9
18)
Manish wants to select all the records from a table named “Students” where the value of
the column “FirstName” ends with an “a”. Which of the following SQL statement will do
this?
a. SELECT * FROM Students WHERE FirstName = ‘a’;
b. SELECT * FROM Students WHERE FirstName LIKE ‘a%’;
c. SELECT * FROM Students WHERE FirstName LIKE ‘%a’;
d. SELECT * FROM Students WHERE FirstName = ‘%a%’;

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 29


Ans:-
d. SELECT * FROM Students WHERE FirstName = ‘%a%’;

19) The command can be used to add a new column to the table.
Ans:- ALTER
20) Which SQL command is used to describe the structure of the table ?
Ans:- DESC
21) Foreign Key in a table is used to enforce
i) Data dependency
ii) Referential Integrity
iii) Views
iv) Index Locations
Ans:- ii) Referential Integrity
22) A table ‘Student’ contains 5 rows and 4 columns initially. 2 more rows are added and 1
more column is added . What will be the degree and cardinality of the table student
after adding these rows and columns?
i) 7, 5
ii) 5,7
iii) 5,5
iv) None of the above
Ans:- ii) 5,7
23) Insert into student values(1,’ABC’,’10 Hari Nagar’) is a type of which command :
i) DML
ii) DDL
iii) TCL
iv) DCL
Ans:- i) DML
24) What will be the output of - select mid('Pyhton Programming’,3,9);
i) ton Progr
ii) ton Progr
iii) hton Prog
iv) htonProg
Ans:- iii) hton Prog
25) Write the output of the following SQL statement:
SELECT TRUNCATE(15.79,-1) , TRUNCATE(15.79,0), TRUNCATE(15.79,1);

a. 15 15 15.7
b. 10 15.7 15.9
c. 10 15 15.7
d. 10 10 15.9

Ans:- c. 10 15 15.7
26) The COUNT( ) in MySQL is an example of :
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- d. Aggregate Funcion
27) …….. which of the following sublanguages of SQL is used to query information from the
database and to insert tuples into, delete tuples from and modify tuples in the database?

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 30


a. DML
b. DDL
c. Query
d. Relational Schema
Ans:- a. DML
28) The ……… clause of SELECT query allows us to select only those rows in the result that
satisfied a specified condition.
a. WHERE
b. FROM
c. HAVING
d. LIKE
Ans:- a. WHERE
29)
Write the output of the following SQL command.
select substr(“COMPUTER”,3,4);
a. MPUT
b. PUTE
c. PU
d. MP
Ans: - a. MPUT
30)
The now() function in MySql is an example of ___________________.
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans :- c. Date Function
31) The _________ command is used to make the changes in a table permanent.
Ans:- COMMIT
32) Give SQL command that will display the current month from the date and time.
Ans :- MONTH( )
33) Which of the following keywords will you use in the following query to display all the
records of students whose name start with S?
SELECT * from student where name “S%”

Ans :- LIKE
34) Which of the following is an aggregate function:
a. Upper()
b. Trim()
c. Date()
d. Sum()

Ans:- d. SUM()

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 31


35) Write the output of the following SQL command:
SELECT left(“Jammu Region”, 5);
a. Region
b. Jammu
c. Jammu Region
d. None of the above.
Ans:- b. Jammu
36)
What will be the output of the following code?

SELECT MOD(14,3);
Ans: 2
37)
What will be the result of the following query based on the table given here.
SELECT COUNT(Salary) FROM Instructor;

Ans:- COUNT(Salary)
--------------------
5
38) Write the command to delete all the data of the table ‘activity’ retaining only structure.
Ans:- DELETE FROM ACTIVITY;
39) Write the output for the following SQL commands
Select round(15.193 , -1);
Ans:- 10
40) Write a SQL query to display date after 20 days of current date on your system.
Ans:- SELECT CURDATE( ) + 10;
41) Write the output for the following sql command
Select SUBSTR(‘ABCDEFG’, -5 ,3)
Ans:- CDE
42) Which keyword is used to arrange the result of order by clause in descending order?
a. DSEC
b. DES
c. DESC
d. DESNO
Ans: C. DESC
43) Write the output of the following SQL command.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 32


Select round(14.872,1)
a)14.87
b)14.9
c)14.8
d) 15
Ans:- b) 14.9
44) The command can be used to change the size of column to the
table.
Ans:- ALTER
45) The command can be used to makes changes in the
rows of a table in SQL.
Ans:- Update
46) Write the output of the following SQL command.
select round (49.88);
a. 49.88
b. 49.8
c. 49.0
d. 50
Ans:- d. 50
47) Write the output of the following SQL command.
select round (19.88,1);
a. 19.88 b. 19.8 c. 19.9 d. 20.0
Ans:- c. 19.9
48) Select count(*) from Employee;
The above query will not consider the following:
a) Numeric value b) Text value c) Null value d) Date value
Ans:- c) NULL Value
49) Which of the following is/are not correct aggregate functions in SQL:
a. AVG() b) COUNT() c) TOTAL() d) MAX()

Ans:- c) Total( )
50) The command can be used to make changes in the definition of a table in SQL.
Ans:- ALTER
51) Write the SQL clause used to sort the records of a table.
Ans:- ORDER BY
52) Write the output of the following SQL command.
select round(15.857,-1);
a. 15.8
b. 15.9
c. 15.0
d. 20
Ans:- 20
53) The now()function in MySql is an example of .

a. Math function
b. Text function
c. Date Function
d. Aggregate Function

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 33


Ans:- c. Date Function
54) The command can be used to makes changes in the structure
of a table in SQL.
Ans:- ALTER
55) Write the SQL command that will display the time and date at which the
command got executed.
Ans: SELECT NOW();
56) In SQL NULL value means :
(i) 0 value (ii) 1 value (iii) None value (iv) None of the above
Ans:- iii) None value
57) Find the output of SQL Query:-
SELECT MOD(11, 3);
Ans:- 2
58) The MAX() function in MySql is an example of
___________________.
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- d. Aggregate Function
59) Write the output of the following SQL command.
select round(314.82,-1);
a. 314.0 b. 310.0 c. 314.8 d. 300.0
Ans:- d. 300
60) What will be the output of the following SQL command:
SELECT LTRIM(“ RAJKUMAR “);
Ans:- “RAJKUMAR “
(Removes spaces from left side)
61) Write the output of the following SQL command.
select pow(2.37,3.45);
a. 17.62
b. 19.62
c. 18.35
d. 15.82

Ans:- b. 19.62
62) Having clause is used with ____________________________function.
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- Aggregate Function
63) Write the output of the query:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 34


select instr('Toolbarbar','bar');
Ans:- 5
64) alter() function in MySql is part of ___________________
a. DDL command
b. DML Command
c. TCL command

Ans a. DDL Command


1 mark for the correct answer
65) The ____________command can be used to arrange data in some order in a table in SQL.
Ans:- ORDER BY
66) Write the name of the clause used with SELECT command to search for a specific pattern in
the strings.
Ans:- LIKE

[2 marks question]

1) State any two differences between single row functions and multiple row functions.
OR
What is the difference between the order by and group by clause when used along with the
select statement. Explain with an example.
Ans:- Differences between single row functions and multiple row functions. (i) Single row functions work
on one row only whereas multiple row functions group rows (ii) Single row functions return one
output per row whereas multiple row functions return only one output for a specified group of
rows.

OR The order by clause is used to show the contents of a table/relation in a sorted manner with
respect to the column mentioned after the order by clause. The contents of the column can be
arranged in ascending or descending order.

The group by clause is used to group rows in a given column and then apply an aggregate function
eg max(), min() etc on the entire group. (any other relevant answer)

Single row v/s Multiple row functions 1 mark for each valid point

Group by v/s Order by 1 mark for correct explanation 1 mark for appropriate example
2) Consider the decimal number x with value 8459.2654. Write commands in SQL to: i. round it off
to a whole number ii. round it to 2 places before the decimal.

Ans:- i. select round(8459.2654);


ii. select round(8459.2654,-2);

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 35


1 mark each for correct answer of part (i) , (ii)
3) Anjali writes the following commands with respect to a table employee having fields, empno,
name, department, commission.
Command1 : Select count(*) from employee;
Command2: Select count(commission) from employee;

She gets the output as 4 for the first command but gets an output 3 for the second command.
Explain the output with justification.
Ans:- This is because the column commission contains a NULL value and the aggregate functions do not
take into account NULL values. Thus Command1 returns the total number of records in the table
whereas Command2 returns the total number of non NULL values in the column commission.
4) Consider the following SQL string: “Preoccupied”

Write commands to display:

a. “occupied” b. “cup”

OR

Considering the same string “Preoccupied” Write SQL commands to display:

a. the position of the substring ‘cup’ in the string “Preoccupied” b. the first 4 letters of the string

Ans:- a. select substr("Preoccupied", 4);


or
select substring("Preoccupied", 4);
or
select mid("Preoccupied",4);
or
select right(("Preoccupied"”, 8);

b. select substr("Preoccupied" ,6,3);


or
select substring("Preoccupied", 6,3);
or
select mid(("Preoccupied" ,6,3);

OR

a. select instr 'Preoccupied' , ‘ 'cup'));


b. select left 'Preoccupied',4);

1 mark for each correct answer of part (a) , (b)


5) What is the difference between the where and Having clause when used along
with the select statement. Explain with an example.
OR

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 36


Explain the difference between Update and Alter command with help of an
example.
Ans Where clause is used to apply condition on individual rows and not supports aggregate function
While Having clause is used to apply condition on groups and it supports aggregate functions.

Eg: SELECT * FROM EMP WHERE SALARY > 50000;

Eg: SELECT * FROM EMP GROUP BY DEPTNO HAVING COUNT(*) > 2;

OR

UPDATE command is a part of DML command and used to update the data of rows of a table.
While ALTER command is a part of DDL command and used to change the structure of a table like
adding column, removing it or modifying the datatype of columns.
Eg: UPDATE EMP SET SALARY = 20000;

ALTER EMP ADD EMP_DOJ DATE;


6) Write the output of following queries:-
i. SELECT SUBSTR('Aakila', -3);
ii. SELECT LEFT(‘Toolbar’, 4);
Ans:- I. ‘ila’
II. ‘Tool’
7) Raghav writes the following commands with respect to a table Flight having
Fields FLCODE, START, DESTINATION, NO_STOPS.
Command1 : Select count(*) from FLIGHT;
Command2: Select count(DESTINATION) from FLIGHT;
He gets the output as 5 for the first command but gets an output 3 for the
second command. Explain the output with justification.

Ans:- This is because the column DESTINATION contains a NULL value and the aggregate functions do not
take into account NULL values. Thus Command1 returns the total number of records in the table
whereas Command2 returns the total number of non NULL values in the column DESTINATION.
8) Write the output for following queries:
i. select MOD(11,4) "Modulus", power(3,2) "Raised";
ii. select CURDATE( )+10;
OR
i. select length('CORONA COVID-19');
ii. select lcase('COMputer Science');

Ans:- i. Modulus Raised


-------------- ----------
3 9

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 37


ii. currentdate + 10 days aftward date will come

or

i. 15
ii. ‘computer science’
9) Consider the decimal number x with value 7459.3654. Write commands in
SQL to:
i) round it off to a whole number
ii) round it to 2 places before the decimal.

Ans:- (i) select round(7459.3654, 0)


(ii) select round(7459.3654, -2)

10) Shailly writes the following commands with respect to a table Employee
having fields, empno, name, department, commission.
Command1 : SELECT COUNT(*) FROM EMPLOYEE;
Command2 : SELECT COUNT(COMMISSION) FROM EMPLOYEE;

She gets the output as 7 for the first command but gets an output 5 for the
second command. Explain the output with justification.

Ans:- This is because the column commission contains a NULL value and the aggregate
functions do not take into account NULL values. Thus Command1 returns the total
number of records in the table whereas Command2 returns the total number of
non NULL values in the column commission.

11) Consider the following SQL string: “SELFMOTIVATION”. Write commands to


display:
a. “MOTIVATION”
b. “MOT”

OR

Considering the same string “SELFMOTIVATION”. Write SQL commands to


display:
a. the position of the substring ‘MOTIV’ in the string “SELFMOTIVATION”
b. the last 6 letters of the string

Ans:- a. select substr(“SELFMOTIVATION”, 5)


b. select substr(“SELFMOTIVATION”, 5, 3)

OR

a. select instr(“SELFMOTIVATION”, “MOTIV”)


b. select right(“SELFMOTIVATION”, 6)

(student may use other functions like – substring/ mid/ right .. etc

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 38


12) State any two differences between Update and alter commands.
OR
What is datatype? What are the main objectives of datatypes?

Ans:- Data types are mean to identify the type of data and its associated functions.
The main objectives of datatypes is to clarify the type of data a variable can store and which
operations can be performed on it.
13) Consider the decimal number n with value 278.6975. Write commands in SQL :
i. That gives output 279
ii. That gives output 280

Ans:- i) select round(278.6975);


(ii) select round(278.6975,-1);
or some other queries that produces same results.
1 mark each for correct answer of part (i) , (ii)
14) (i) Consider a table “Employee” that have fields - empno, name, department, salary.
Based on the above table “Employee”, Manvendra has entered the following SQL command:
SELECT * FROM Employee where Salary = NULL;

But the Query is not executing successfully. What do you suggest to him in order to execute this
query i.e. write the correct query.

(ii) Write a SQL query to display the details of those employees whose Salary column has some
values.

Ans:- (i) select * from Employee where Salary is NULL;


(ii) select * from Employee where Salary is not NULL;

1 mark each for correct answer of part (i) , (ii)


15) Consider the following SQL string: “Master Planner”.
Write commands to display:
a. “Master”
b. “Plan”
OR
Considering the same string “Master Planner”.
Write SQL commands to display:
a. the position of the substring ‘Plan’ in the string “Master Planner”
b. the Last 4 letters of the string

Ans:- a. select substr("Master Planner",1,6);


b. select substr("Master Planner",8,4); or some other queries that produces same results.

1 mark each for correct answer of part (i) , (ii)

OR
a. select instr("Master Planner","Plan");
b. select right("Master Planner",4); or some other queries that produces same results.

1 mark each for correct answer of part (i) , (ii)


16) What are multiple row functions? Give examples

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 39


OR
What is Group by clause? How can we specify condition with Group by clause? Explain with an
example.
Ans:-
17) Consider the decimal number N with value 87654.9876. Write commands in SQL to:
i. round it off to a whole number
ii. round it to 2 places before the decimal.
Ans:-
18) State any two differences between single row functions and multiple row functions.
OR
What is the difference between the order by and group by clause when used along with the
select statement. Explain with an example.
Ans:- 19. Differences between single row functions and multiple row functions.
(i) Single row functions work on one row only whereas multiple row functions group rows
(ii) Single row functions return one output per row whereas multiple row functions return
only one output for a specified group of rows.
OR
The order by clause is used to show the contents of a table/relation in a sorted manner
with respect to the column mentioned after the order by clause. The contents of the
column can be arranged in ascending or descending order.
The group by clause is used to group rows in a given column and then apply an aggregate
function eg max(), min() etc on the entire group. (any other relevant answer)
Single row v/s Multiple row functions 1 mark for each valid point
Group by v/s Order by 1 mark for correct explanation 1 mark for appropriate example

19) Give the output of :


i) Select round(123.93);
ii) Select round(123.93,1);
Ans:- i) 124
ii) 123.9

20) Consider the following SQL string: “Mental Toughness Helps You
Succeed” Write commands to display following using functions:
a. “Toughness”
b. “Succeed”
OR
Considering the same string: “Mental Toughness Helps You Succeed”
Write SQL commands to display:
a. the position of the substring ‘’Helps’ in the string “Mental Toughness Helps You Succeed”
the first 6 letters of the string
Ans:- i) Select mid(‘Mental Toughness Helps You Succeed’, 8, 9)
ii) Select right(‘Mental Toughness Helps You Succeed’, 7);
OR
i) select instr("Mental Toughness Helps You Succeed",’Helps’);
ii) select left("Mental Toughness Helps You Succeed",6);
1 Mark each for correct function usage

21) Find out the error in the following SQL command and correct the same.
Select * from employee group by dept where sum(salary) > 2000000

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 40


Ans:- Select * from employee group by dept where sum(salary) > 2000000 in this query in place of
WHERE clause HAVING clause to be used.
22) Helps Abhay to Compare Having clause and Order by clause?
Or

Shewani has recently started working in MySQL. Help her in understanding the
difference between where and having clause.
Ans:- Having clause is used in conjunction with group by clause in MySQL. It is used to provide
condition based on grouped data. On the other hand, order by clause is an independent
clause used to arrange records of a table in either ascending or descending order on the
basis of one or more columns
OR
COUNT(*) returns the number of items in a group, including NULL values and
duplicates. COUNT(expression) evaluates expression for each row in a group and
returns the number of non null values
2 marks of correct explanation & for any other relevant answer.
23) Write commands in SQL to:
i. round off value 56789.8790 to nearest thousand’s place.
ii. Display day from date 13-Apr-2020.
Ans:- i. Select ROUND(56789.8790,-3);
ii. Select DAY(‘2020-04-13’) 1 mark each for correct answer.
24) Given Table Course:

Find out the output for given SQL command:


SELECT TID, COUNT(*), MIN(FEES) FROM COURSE GROUP BY
TID HAVING COUNT(*)>1;
Ans:- Ans:
TID COUNT(*) mIN(FEES)
101 2
12000

2 marks for correct output


25) Consider the following SQL strings: S1= “INDIA” S2=”MY” &
S3=”DI” Write commands to display:
a. “MYINDIA”
b. “india”
OR
Considering the same string as
above Write SQL commands to

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 41


display:
a. The position of the string S3 in the string S1.
The first 4 letters of the concatenation of string S1 and S2.
Ans:- a. Select CONCAT(s2,S1);
b. Select LCASE(S1)
OR
a. Select INSTR(S1,S3);
b. Select LEFT(CONCAT(S1,S2));
1 mark each for correct SQL command.
26) What is importance of primary key in a table? How many primary keys can be there for a
table?
OR
Explain working of TRIM( ) function with proper examples.

Ans:- Primary Key : A column of collection of columns to identify a tuple in a relation. It is used

to search / locate row in a relation. There can be only one primary key in a table. 1 mark
for correct definition with proper significance.
1 mark for stating only one primary key in a table.

OR

TRIM () function is used to remove leading and trailing spaces from a string a table. It can
be used as
TRIM(String)
For example;
SELECT TRIM(' bar ');

-> 'bar'
1 mark for stating purpose of the functions 1 mark for correct example.
27)
Consider the following ‘Student’ table.

(i) What will be the most suitable datatype for the grade column and why?
(ii) Write a command to insert Suman’s record with the data as shown in the
table.

Ans:- (i) Gender column datatype char(1) as all the possible values can be accommodated and it
will be space efficient.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 42


(ii) INSERT INTO Student (Rollno, Sname, Subject, Marks) VALUES (“003”,
”SUMAN”, “IP”, 75);
1 mark for each correct answer
28) Explain the working of ORDER BY clause of SELECT query with proper example.
Ans:- The ORDER BY 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. To sort the records
in descending order, use the DESC keyword.
1 mark for correct explanation. 1 mark for appropriate example
29)
Consider a string “AS YOU know MORE” 2
Write the queries for the following tasks.
(i) Write a command to display “know”.
(ii) Write a command to display number of characters in the string.
OR
Consider a string “You Grow more” stored in a
column str. What will be the output of the following
queries?
(i) SELECT UPPER(str);
(ii) SELECT substr(str,-9,4);

Ans:- (i) select mid(“AS YOU know MORE”,8,4);


(ii) select length(“AS YOU know MORE”);

OR

(i) YOU GROW MORE


(ii) Grow
1 mark for each correct answer

[3 marks question]

1) A relation Vehicles is given below :

Write SQL commands to:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 43


a. Display the average price of each type of vehicle having quantity more than 20.
b. Count the type of vehicles manufactured by each company.
c. Display the total price of all the types of vehicles.

Ans:- a. select Type, avg(Price) from Vehicle group by Type having Qty>20;
b. select Company, count(distinct Type) from Vehicle group by Company;
c. Select Type, sum(Price* Qty) from Vehicle group by Type;

a. ½ mark for the Select with avg(), ½ mark for the having clause
b. ½ mark for the Select with count() , ½ mark for group by clause
c. ½ mark for the Select with sum() , ½ mark for the group by clause
2) Consider the table Garment and write the query:

i. Display the Minimum price of the Garment.


ii. Count and display the number of GARMENT from each SIZE where number of
GARMENTS are more than 1
iii. Display the sum of price of each color garment
Ans:- i. SELECT MIN(PRICE) FROM GARMENT;
ii. SELECT SIZE,COUNT(*) FROM GARMENT
GROUP BY SIZE
HAVING COUNT(*)>1;
iii. SELECT COLOUR,SUM(PRICE) FROM GARMENT GROUP BY COLOUR;

3) A relation SALESMAN is given below:

SNO SNAME SALARY BONUS DATEOFJOIN AREA


A01 Kushagra Jain 30000 45.25 29-10-2019 Delhi
A02 Prakhar Sharma 50000 25.50 13-03-2018 Ajmer
B03 Trapti Singh 30000 35.00 18-03-2017 Jhansi
B04 Shailly 80000 45.00 31-12-2018 Delhi
C05 Lakshay Lawania 20000 10.25 23-01-1989 Jaipur
C06 Naresh 70000 12.75 15-06-1987 Ajmer
D07 Krishna Singh 50000 27.50 18-03-1999 Jhansi

Write SQL commands to perform the following operations:


i) Count the number of salesman area-wise.
ii) Display the month name for the date of join of salesman of area ‘Ajmer’
iii) Display the total salary paid to all salesman.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 44


Ans:- (i) select area, count(sname) as “Number of salesman” from Salesman group by area;
(ii) select monthname(dateofjoin) from Salesman where area=’Ajmer’;
(iii) select sum(salary) from Salesman;

4) Consider the given table Faculty :-


Faculty_Id First_name Last_name Hire_date Salary
1102 Sulekha Mishra 12-10-1997 25000
1203 Naveen Vyas 23-12-1994 18000
1404 Rakshit Soni 25-08-2003 32000
1605 Rashmi Malhotra 18-09-2004 21000
1906 Amit Srivastava 05-06-2007 28000
Write SQL commands to :
a. To display details of those faculty members whose First_name ends with ‘t’.
b. Display all records in descending order of Hire_date.
c. Find the maximum and minimum salary.
Ans:- a. Select * from Faculty where First_name like ‘%t’;
b. Select * from Faculty order by Hire_date desc;
c. Select max(Salary), min(Salary) from Faculty;
1 mark for each correct answer
5) Given the table CARDEN having following data:

CCode CarName Company Color Capacity Charges


501 A-Star Suzuki Red 3 14
503 Indigo Tata Silver 3 12
502 Innova Toyota White 7 15
509 Qualis Toyota Silver 4 14
510 Wagon R Suzuki Red 4 35
Write SQL Commands for the following :
a. Display the average charges of each type of car company having capacity more than 3.
b. Count the totalcars manufactured by each company.
c. Display the total charges of all the types of vehicles.
Ans a. select company, avg(charges) from carden group by company having capacity>3;
b. select Company, count(*) from carden group by Company;
c. Select company, sum(charges) from carden group by company;
1 mark each for correct answer

6) TABLE NAME : PHARMADB

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 45


Write SQLcommands to a & b and ouput for c:
a. To display sum of price for each PharmacyName having more than 1 drug.
b. Display pharmacy name in descending order of drug id
c. SELECT PharmacyName, COUNT(*) FROM PharmaDB GROUP BY PHARMACY NAME

Ans:-
a. Select sum(price) from pharmadb group by pharmacyname having count(*)>1;
b. Select PharmacyName from Pharmadb order by DrugID;

a. ½ mark for the Select with sum(), ½ mark for the having clause
b. ½ mark for the Select ,½ mark for the order by clause
1 marks for correct output.
7) Consider a MySQL table ‘product’

P_ID PROD_NAME PROD_PRICE PROD_QTY


P01 Notebook 85 500
P02 Pencil Box 76 200
P03 Water Bottle 129 50
P04 School Bag 739 70

(i) Display maximum PROD_QTY.

(ii) Display the value of each product where the value of each product is
calculated as PROD_PRICE * PROD_QTY
(iii) Display average PROD_PRICE.

Ans:- (i) SELECT MAX(PROD_QTY) FROM product;


(ii) SELECT PROD_PRICE*PROD_QTY AS ‘Value’ FROM product;
(iii) SELECT AVG(PROD_PRICE) FROM product;

1 mark for each correct query

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 46


[5 marks question]
1) Write the SQL functions which will perform the following operations:
i) To display the name of the month of the current date .
ii) To remove spaces from the beginning and end of a string, “ Panorama “.
iii) To display the name of the day eg, Friday or Sunday from your date of birth, dob.
iv) To display the starting position of your first name(fname) from your whole name (name).
v) To compute the remainder of division between two numbers, n1 and n2

OR

Consider a table SALESMAN with the following data:

Write SQL queries using SQL functions to perform the following operations:
a) Display salesman name and bonus after rounding off to zero decimal places.
b) Display the position of occurrence of the string “ta” in salesman names.
c) Display the four characters from salesman name starting from second character.
d) Display the month name for the date of join of salesman
e) Display the name of the weekday for the date of join of salesman
Ans:- i) monthname(date(now()))
ii) trim(“ Panaroma “)
iii) dayname(date(dob))
iv) instr(name, fname)
v) mod(n1,n2)
1 mark for each correct answer

OR

i) Select sname, round(bonus,0) from Salesman;


ii) Select instr(Sname, “ta”) from Salesman;
iii) Select mid(Sname,2,4) from Salesman; alternative answer
iv) Select Substring(Sname,2,4) from Salesman; iv) Select monthname(DateofJoin) from
Salesman;
v) Select dayname(DateofJoin) from Salesman;
1/2 mark each for correct usage of Select and round()
1/2 mark each for correct usage of Select and instr()
1/2 mark each for correct usage of Select and substr()
1/2 mark each for correct usage of Select and monthname()
1/2 mark each for correct usage of Select and dayname()

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 47


Note : Instead of substr() , substring() may be accepted as correct
2) Consider a table Teacher with the following data:

Write SQL queries using SQL functions to perform the following operations:
a) Convert all the names into lower case.
b) Display the position of occurrence of the string “sh” in Name.
c) Display the four characters from Department starting from second character.
d) Display the month name for the date of admission.
e) Display the name of the weekday for the date of admission.
OR
Write the SQL functions which will perform the following operations:
i) To display the day of month of current date.
ii) To remove spaces from the beginning and end of a string, “ Informatics Practices “.
iii) To display the name of the day eg. Friday or Sunday from your date of birth, dob.
iv) To convert your name into Upper case.
v) To compute the mode of two numbers num1 and num2.

Ans:- i. SELECT LOWER(NAME) FROM TEACHER;


ii. SELECT INSTR(NAME, ‘sh’) FROM TEACHER;
iii. SELECT MID(Department, 2,4) FROM TEACHER;
iv. SELECT MONTHNAME(DateofAdm) FROM TEACHER;
v. SELECT DAYNAME(DateofAdm) FROM TEACHER;

OR

i. SELECT DAYOFMONT(CURDATE());
ii. SELECT TRIM(“ Informatics Practices “;
iii. SELECT DAYNAME(“2015-07-27”);
iv. SELECT UPPER(Name);
v. SELECT MOD(num1,num2);

3) Write the SQL functions which will perform the following operations:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 48


i) To display the name of the month of the current date.
ii) To remove spaces from the beginning and end of a string, “ KV Sangathan “.
iii) To display the name of the day eg, Friday or Sunday from your date of birth, dob.
iv) To print the value of square root of 2 upto 2 decimal points.
v) To compute the remainder of division between two numbers, n1 and n2
OR
Write SQL for question from (i) to (iv) and output for SQL queries (v) and (vi), which are based on the
table: KV given below:

(i) Print the details of KVs whose StationCode between 300 and 500
(ii) Print the details of KVs whose name ends with AFS
(iii) Print the details of KVs of Jaipur region
(iv) Print the number of KVs Zone-wise
(v) Select Region, count(KVName) from KV where Zone=’West’ group by Region
(vi) Select * from KV where substr(KVName, 2, 3)=’and’ or StationCode=390;

(i) select month(current_date());


(ii) select trim(“ KV Sangathan “);
Ans:- (iii) select dayname(dob) from student;
(iv) select round(sqrt(2) , 2);
(v) select n1 % n2;

OR

(i) Select * from KV where StationCode between 300 and 500;


(ii) Select * from KV where KVName like ‘%AFS’;
(iii) select * from KV where Region=’Jaipur’;
(iv) select Zone, count(KVName) from KV group by Zone;
(v) Region count(KVName)
Ahmedabad 2
Jaipur 3
(vi)
KVCode KVName StationCode Region Zone
1019 Gandhidham IFFCO 11 Ahmedabad West
1020 Gandhidham Railway 11 Ahmedabad West
1702 Uri 390 Jammu North

4) Write the SQL statement for the following:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 49


i) To display names “Mr. James” and “Ms. Smith” in lower case.
ii) To display current date and time.
iii) To extract date from a given datetime value ‘2020-12-21 09:30:37’.
iv) To remove trailing spaces from string “ Technology Works ”
v) To compute the remainder of division between 125 and 17.

OR
Consider the following table Garments. Write SQL commands for the following statements.
Table : Garments
GCode GName Price MCode Launch_Date
10001 Formal Shirt 1250 M001 2008-12-12
10020 Frock 750 M004 2007-09-07
10007 Formal Pant 1450 M001 2008-03-09
10024 Denim Pant 1400 M003 2007-04-07
10090 T-Shirt 800 M002 2009-05-12
a) To update the Price of Frock to 825.
b) To print the average price of all the Garments.
c) To display the Garments Name with their price increased by 15%.
d) To delete the rows having MCode as M002.
e) To display the details of all the Garments which have GCode less than 10030.
Ans:- (i) select lower(“Mr. James”), lower(“Ms. Smith”);
(ii) select now();
(iii) select date(“2020-12-21 09:30:37”);
(iv) select rtrim(“ Technology Works ”);
(v) select mod(125,17);

1 mark for each correct answer

OR
a. Update Garments set price=825 where GName=’Frock’;
b. select avg(price) from Garments;
c. select DName, price*1.15 as ‘Increased_Price’ from Garments;
d. delete from Garments where MCode=’M002’;
e. select * from Garments where GCode<10030;

1 mark for each correct answer


5) Write the SQL functions which will perform the following operations:
i) To display the name of the month of your birthdate .
ii) To remove spaces from the beginning of a string, “ Python“.
iii) To display the day of the week eg, Sunday from current date.
iv) To display the starting 3 characters from your name .
v) To compute the power of 2 to the power 3
OR

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 50


Consider the table : Shop
Id SName Area Bonus DateofOpen
S001 ABC CP 1000.89 2010-11-20
Computronics
S002 All Infotech GK II 2345.987 2015-09-12
S003 Tech Shoppe CP 761.46 2013-07-25
S004 Geek Tenco Soft Nehru 456.923 2019-10-10
Place
S005 Hitech Solution GK II 1000.025 2008-12-20

a) Display shop name and bonus after rounding off to zero decimal places.
b) Display the position of occurrence of the string “tech” in shop names.
c) Display three characters from shop name starting from second character.
d) Display the month name for the date of opening of shop
e) Display the name of the shop in all capitals.

Ans:- i)select monthname(‘1998-11-20’);


ii)select ltrim(‘ Python’);
iii)select dayname(now());
iv)select left(‘Nitin’,3);
v)Select power(2,3);
1 mark each for correct function
OR
a) Select Sname,round(Bonus,0) from Shop;
b) Select instr(SName,’tech’) from Shop;
c) Select mid(SName,2,3) from Shop;
d) Select monthname(DateOfOpen) from shop;
e) Select Upper(SName) from shop;
1 mark each for the correct query

6) Consider the following data frame of automobile

Write SQL queries using SQL functions to perform the following operations:
a) Display company name and body wheel base after rounding off to nearest ten’s decimalplaces.
b) Display the position of occurrence of the string “dan” in body style.
c) Display the 3 characters from company name starting from second character.
d) Display the year of manufacturing for sedan;

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 51


e) Display the name of the weekday for the manufacturing date.
Ans:- a) Select company, round(wheel-base,-1) from automobile;
b) Select instr(body-style,’dan’) from automobile;
c) Select substr(company,2,3) from automobile; /mid(company,2,3)
d) Select year(dateofmanufacture) from automobile where body-style=’sedan’;
e) Select dayname(dateofmanufacture) from automobile;

a) 1/2 mark each for correct usage of Select and round()


b) 1/2 mark each for correct usage of Select and instr()
c) 1/2 mark each for correct usage of Select and substr()
d) 1/2 mark each for correct usage of Select year and where clause
1/2 mark each
7) Consider the below mentioned table of ‘CLOTH’
DCODE DESCRIPTION PRICE MCODE LAUNCHDATE
10001 FORMAL SHIRT 1250 M001 12–JAN–08
10020 FROCK 750 M004 09–SEP–07
10012 INFORMAL SHIRT 1450 M002 06–JUN–08
10019 EVENING GOWN 850 M003 06–JUN–08
10090 TULIP SKIRT 850 M002 31–MAR–07
10023 PENCIL SKIRT 1250 M003 19–DEC–08
10089 SLACKS 850 M003 20–OCT–08
Write the commands for the following:
(i) Display first three letters of description e.g. ‘FRO’ for ‘FROCK’
(ii) Display the description after removing leading spaces if any.
(iii) Display number of characters taken by each description.
(iv) Display the number of MCODE in the table.
(v) Display the day of the LAUNCHDATE. Eg. ‘Monday’, ’Tuesday’ etc
OR
(i) Display total price of products launched in year 2008.
(ii) Display minimum price of product for each material code(MCODE).
(iii) Display the most recent LAUNCHDATE.
(iv) Display the description in lower case alphabets.
(v) Display remainder of price divided by 10.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 52


CHAPTER-4 01
Computer Networks
Introduction:
Computer Network is a collection of autonomous computers interconnected by a single
technology. Two or more computers are said to be interconnected if they are able to exchange
information. A computer network is a system that connects independent computers in order to
share information and resources.

Brief History of Network


➢ In 1967, ARPA (Advance Research Project Agency by Department of Defence)
proposed the idea of ARPANET – a small network of computers.
➢ By 1969, ARPANET became reality that connect four nodes at University of California
at Los Angeles (UCLA), University of California at Santa Barbara (UCSB), Stanford
Research Institute (SRI) and University of Utah vai IMPs ( Interface Message
Processor – a specialized computer).
➢ In 1973, Vint Cerf and Bob Kahn presented paper outlined the protocol(
Transmission Control Protocol) to achieve end-to-end delivery of packets.

Advantage of Computer Network:


➢ Central Storage of Data
➢ Sharing of Information
➢ Sharing of Resources(Hardware & Software)
➢ Reliability
➢ Communication
➢ Reduced Cost

Disadvantage of Computer Network:


➢ Computer networks require a specific setup
➢ Lack of Security
➢ Cost of network hardware and software

Components of Data Communication:


➢ Message – it information to be communicated
➢ Sender – The device which send the message
➢ Receiver – The device which receive the message
➢ Transmission media – It is physical path by which message travel from sender to
receiver
➢ Protocol – It is set of rules that governs data communication. Actually it is
agreement between the sender and receiver regarding various communication
parameter.

Data Flow
➢ Simplex – In this mode of communication, data is transmitted in one direction only.
e.g. Keyboard, monitor. It uses entire capacity of channel to send the data.
➢ Half Duplex – Communication is bi-directional but not same time. i.e. Walkie-Talkie.
It uses entire capacity of channel is utilized for each direction.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 53


➢ Full Duplex – Communications is bi-directional simultaneously i.e. both sender and
receiver can be send data at same time.
Network Terminology
➢ Node- The device connected to a network.
➢ Client – The device that request for a service
➢ Server – The Device that render the services
➢ Client-Server - In this model, the data are stored on powerful computers called
Server that can be accessed by a much simpler computer called Client that are
connected by a network.

➢ Network Interface Card or Unit (Network Adapter or LAN card) - It is hardware that
allows a computer (or device) to connect to network.
➢ MAC (Media Access Control) address – Each NIC is assigned a unique 12 digit
hexadecimal number, known a MAC address, is used as network address in
communication. The format for the MAC address is

MM : MM : MM : SS : SS : SS

Manufacturer ID Card Id
➢ IP Address: Every device on network has unique identifier called IP address. It
consists of 4 bytes (IPv4) decimal number (between 0 to 255) separated by ‘.’
(Period).
➢ Channel – It is communication path through which data is actually transmitted.
➢ Communication Media- It is allows data or signal to be communicated across the
devices. It is means of communication.
➢ Data – Information stored within the computer system in form of ‘0’ and ‘1’
➢ Signal- It is electric or electromagnetic encoding of data to be transmitted. It can be
categorized into :
o Analog Signal – that has infinitely many level of intensity over a period of
time.
o Digital Signal – that can have only a limited number of defined values.
➢ Bit rate – It defines the amount of data transferred. It is defined as number of bits
per second (bps). [Bps – Bytes per Second]
➢ Baud – The number of changes in signal per second.
➢ Bandwidth – It is difference between the highest and the lowest frequencies
contained in the signal.

Mode of Transmission
➢ Analog or Broadband Transmission
• It uses analog signals to transmit the information

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 54


• The data can be sent simultaneously using various frequencies.
• It is a unidirectional method of data transmission.
• Multiple signals can be transmitted using multiple frequencies using only one
channel
• Signal range is long.
• Example- Used to transmit cable TV to premises

➢ Digital or baseband Transmission


• It uses digital signal (square wave) to transmit the information.
• It is bi-directional transmission.
• Entire bandwidth is for single signal transmission.
• Short distance signal travelling
• Ethernet is using Basebands for LAN

➢ Parallel Communication
➢ Series Communication
➢ Synchronous Transmission
➢ Asynchronous Transmission

Switching Technique
➢ A switched network consists of a series of interlinked nodes called switches capable of
creating temporary connections between two or more liked devices.
➢ There are three basic switching technique
• Circuit –Switching
• Packet Switching
• Message Switching
Circuit Switching vs Packet Switching

Network Devices
➢ Modem
• It stands for modulator and demodulator
• It a computer hardware device that converts data from a digital format into a format
suitable for an analog.
• A modem transmits data by modulating one or more carrier wave signals to encode
digital information, while the receiver demodulates the signal to recreate the original
digital information.

➢ Repeater
• Repeaters are network devices that amplify or regenerate an incoming signal before
retransmitting it.
• It operate at physical layer of the OSI model.
• The repeater allows to transfer the data through large area distance

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 55


➢ Hub
• It is a multiport device that allows multiple computers to communicate with each other
over a network.
• It is a non-intelligent network device that sends message to all ports( i.e. Broadcast)
• Types of Hub
• Active Hub –
• It strengthen the signal may boost noise too.
• It need electricity.
• Passive Hub –
• It repeat/copy signals.
• It does not need electricity

➢ Switch
• Network Switch or switch is also a network multiport device that allow multiple
computer to connect together.
• Network switch inspects the packet, determine source and destination address and
route the packet accordingly.
• It operates at Data Link Layer (layer 2) of OSI model.

➢ Bridge
• It connects multiple network segments having same protocol
• It works at Data Link Layer (Layer 2).
• Bridge does not simply broadcast traffic from one network.
• Bridges use bridge table to send frames across network segments.
• It also improves the overall network performance.

➢ Router
➢ Gateway
➢ RJ45
➢ Ethernet Card
➢ Wi-Fi card
Type of Network

➢ PAN
• It stands for Personal Area Network.
• It is a computer network formed around a person.
• It generally consists of a computer, mobile, or personal digital assistant.
• Appliances use for PAN: cordless mice, keyboards, and Bluetooth systems.
• PAN includes mobile devices, tablet, and laptop.
➢ LAN
❖ It is a group of computer and peripheral devices which are connected in a limited area
such as room, building & campus.
❖ Higher Data Speed.
❖ Lower Error Rate.
❖ LANs are in a narrower geographic scope (upto 1 Km).
❖ It is a private network.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 56


➢ MAN
❖ A Metropolitan Area Network or MAN is consisting of a computer network that span
across a city.
❖ It mostly covers towns and cities in a maximum 50 km range.
❖ The dual bus in MAN network provides support to transmit data in both directions
concurrently.
❖ Moderate Data Rate.
❖ Moderate Error Rate.

➢ WAN
❖ It connect device across globe.
❖ It uses public network
❖ Internet
❖ BSNL
❖ VSNL

Network Media

Twisted Pair Cable


➢ A twisted pair cable comprises of two separate insulated copper wires, which are twisted
together and run in parallel.
❖ A STP (Shielded Twisted Pair) cable has a fine wire mesh surrounding the wires to
protect the transmission
❖ UTP (Unshielded Twisted Pair) cable does not has a fine wire mess.
➢ It is also known as Cat# cable where # denote number. e.g. Cat6
➢ Connector : RJ 45

Twisted Pair Cable – Advantages


➢ It is the least expensive medium of transmission for short distances.
➢ It is relatively easy to implement and terminate.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 57


➢ It is flexible and lightweight.
➢ It is easy to set up and install.
➢ Less susceptible to electrical interference caused by nearby equipment or uses of wires.

Twisted Pair Cable – Disadvantages

➢ Attenuation is very high.


➢ It offers poor noise immunity as the result signal distortion is too much more.
➢ STP called shielded twisted pair cable is more difficult to connect to a terminating block.
➢ Susceptible to noise and interference.

Co-axial Cable
➢ Coaxial cabling has a single copper conductor at its center, and a plastic layer that provides
insulation between the center conductor and a braided metal shield.
➢ Connector: BNC (Bayonet Neill-Concelman)

Co-axial Cable Advantage

➢ The cost of a coaxial cable is less.


➢ Highly resistant to physical damage.
➢ Highly resistant to EMI.
➢ Great channel capacity.
➢ The transmission rate is high.
➢ It is less susceptible to noise interference compare to twisted pair.
➢ It is easy to wire and easy to expand to flexibility.
➢ It support high bandwidth signal transmission compare to twisted pair.
➢ It requires fewer repeater than twisted pair.
Co-axial Cable – Disadvantage:
➢ It is expensive to install.
➢ Cost maintenance is also high.
➢ Inflexible construction.
➢ Unsupported by newer networking standards.
➢ It is bulky.
➢ It has a more security problem.
➢ It does not support high-speed transmission.
➢ It must be grounded to prevent interference.
➢ In case of failure in one cable, the entire network will be down by using this wire.

Optical Fibre

➢ An optical fiber is a flexible, transparent fiber made by drawing glass or plastic to a diameter
slightly thicker than that of a human hair.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 58


➢ It uses light for data transmission using total internal reflection.

Optical Fibre- Advantages

➢ Higher bandwidth
➢ Less signal attenuation
➢ Immune to cross-talk
➢ Optical fiber have long life more than 100 or above years
➢ Grater immune to tapping
➢ Resistance to corrosive material
➢ Long distance transmission is possible
➢ Immunity to electromagnetic interference

Optical Fibre-Disadvantage

➢ Unidirectional propagation
➢ High initial cost
➢ Optical fiber more tensile stress than copper cables
➢ Installation and maintenance
➢ Fiber joining process is very costly and require skilled menpower
➢ Difficult to splice (join)
➢ Difficult to find error

Unguided Media or Wireless Media

➢ No Physical media is used


➢ Less Secure
➢ Relatively low speed
➢ Can be used for longer distance
➢ Best suited for difficult terrain
➢ There is no need to acquire land rights

Radio Wave

➢ Frequency – 3KHz – 1GHz


➢ Omni-Directional
➢ Penetrate obstacle
➢ Antenna of sender and receiver should not be aligned

Infrared

➢ 300GHz to 400THz
➢ Line of sight- antenna of sender and receiver must be aligned
➢ Short distance communication
➢ It cannot penetrate obstacle – best suited for indoor
➢ Secure
➢ Support high data rate
➢ TV Remote

Microwave

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 59


➢ 1GHz to 300 GHz
➢ Line of sight- antenna of sender and receiver must be aligned
➢ Cannot penetrate obstacles
➢ Rain or other disturbance cause issue with Microwave
➢ Types of microwave propagation
❖ Terrestrial Microwave propagation
❖ Satellite Microwave propagation

Bluetooth

➢ It also uses radio waves


➢ 2.4 GHz
➢ Range 10mtr
➢ Short distance

Topology

➢ Physical and Logical arrangement of nodes in the network is called Network Topology.
➢ The Key Elements to be considered to choose correct topology for your network
❖ Length of the Cable Needed – longer the cable, more work is required for setup
❖ Cable Type- Depending on requirement of bandwidth
❖ Cost- Installation Cost and Complexity
❖ Scalability – Ease of expansion
❖ Robustness – Ability to recover from error

Types of Topology

➢ Bus
➢ Ring
➢ Star
➢ Tree
➢ Mess
➢ Hybrid

Bus Topology
➢ In Bus Topology all the nodes are connected to single cable or backbone
➢ Both the end have terminators.

Advantage – Bus Topology

➢ It is easy to connect a device to the network.


➢ It require less cable length.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 60


➢ Low setup cost
➢ There is no need of Hub/Switch.
➢ It can be extended easily.

Disadvantage – Bus Topology

➢ Failure of one node can shutdown entire network


➢ There is a limit on central cable length and number of nodes that can be connected.
➢ Difficult to find and correct errors
➢ Terminator is required.
➢ Maintenance costs can get higher with time.
➢ Not suitable for Big network.
➢ Low Security due to broadcasting of data.

Ring Topology

 In Ring Topology all the nodes are connected to each-other to form a loop.
 Each workstation is connected to two other components on either side
 It communicates with these two adjacent neighbors.
 Data is sent and received using Token.

Advantage – Ring Topology

➢ It is easy to connect a device to the network.


➢ It require less cable length.
➢ Low setup cost
➢ There is no need of Hub/Switch
➢ Minimum collision
➢ Suitable for Optical Fibre Network

Disadvantage – Ring Topology

➢ Failure of one node can shutdown entire network


➢ There is a limit on central cable length and number of nodes that can be connected.
➢ Difficult to find and correct errors.
➢ Maintenance costs can get higher with time.
➢ Not suitable for Big network.
➢ Low Security due to broadcasting of data.
➢ Unidirectional

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 61


Star Topology

➢ In Star Topology all the nodes are connected to a central device called Hub/Switch.
➢ All communication is controlled by the central Device( Hub/Switch)

Advantages –Star Topology

➢ Reliable
➢ Robust
➢ Failure of node does not affect the working of the network.
➢ Fault detection and isolation is easy.
➢ Maintenance of the network is easy.
➢ It doesn’t create bottlenecks where data collisions occur.

Disadvantages – Star Topology

➢ Require more cable length


➢ Central Device dependency
➢ More costly
➢ Performance depend on Hub/Switch

Tree Topology

➢ In Tree Topology, the devices are arranged in a tree fashion similar to the branches of a tree.
➢ It multilayer architecture.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 62


Advantages- Tree Topology

➢ It is a combination of bus and star topology


➢ It provides high scalability, as leaf nodes can add more nodes in the hierarchical chain.
➢ Other nodes in a network are not affected, if one of their nodes get damaged
➢ It provides easy maintenance and fault identification.
➢ Point-to-point wiring for individual segments.

Disadvantages -Tree Topology

➢ Large cabling is required as compared to star and bus topology.


➢ On the failure of a hub, the entire network fails.
➢ Tree network is very difficult to configure than other network topologies.

Protocol

➢ It is set of rules or standard that governs communication.

Types of Protocol

➢ TCP/IP
➢ FTP
➢ HTTP/HTTPS
➢ IMAP
➢ POP3
➢ SMTP
➢ PPP
➢ TELNET
➢ VoIP

TCP/IP – Transmission Control Protocol/ Internet Protocol

➢ It is a protocol suite consist of two protocols Transmission Control Protocol and Internet
Protocol.
➢ TCP ensures reliable transmission or delivery of packets on the network.
➢ TCP is state full protocol.
➢ IP is responsible for addressing of node on the network

HTTP (Hyper Text Transfer Protocol)

➢ It is is an application-layer protocol for transmitting hypermedia documents, such as HTML.


➢ It is designed for communication between Client (Web Browser) and Web Server.
➢ It uses port number 80.
➢ It is stateless protocol.

HTTPS (Secure Hyper Text Transfer Protocol)

➢ It is is an extension of HTTP protocol for transmitting hypermedia documents, such as HTML


securely over a network.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 63


➢ It encrypts data to be sent using TLS (Transport Layer Security)/SSL (Secure Sockets Layer).
➢ The default port is 443.

FTP (File Transmission Protocol)

➢ It is used for the transfer of computer files among hosts over TCP/IP (internet).
➢ It allows access to directories or folders on remote computers.
➢ It uses client-server architecture.
➢ It is statefull protocol
➢ The default port is 21

Telnet (TErminaL NETWork)

➢ It is an application protocol that allows a user to communicate with a remote device.


➢ It uses port no 23

SMTP (Simple Main Transfer Protocol)


➢ It is used to send mail from mail client to mail server over internet.
➢ It can send a single message to one or more recipients.
➢ Sending message can include text, voice, video or graphics.
➢ It is connection Oriented Protocol.

POP3 (Post Office Protocol)

➢ It provides mechanism for retrieving emails from a remote server for a mail recipient.
➢ POP3 downloads the email from a server to a single computer, then deletes the email from
the server.
➢ Default port for POP3 110 and secure port 995

IMAP (Internet Message Access Protocol)

➢ It is also used to retrieve mail from mail server to client over internet (TCP/IP).
➢ It allows access to mail from different device.
➢ E-mail client establishes a connection with the server every time you log in and maintained
for the whole session.
➢ Email will not automatically gets deleted.
➢ Default Port is – 143 and Secure port is 993.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 64


CHAPTER-5 01
Introduction to web Services
Web browser:
➢ A web browser is a program or software or application that helps users to get the data and
information from the webserver. Some commonly used web browsers are Google Chrome,
Mozilla Firefox, Internet Explorer, Opera, Apple Safari etc.

Plug-in or Add on or Extension:


➢ A plug-in or add on or extension is software that adds additional functionality to your web
browser. It adds a number of features to web browsers. For example, enable emoticons,
reading pdfs, languages etc.

Domain names
➢ A domain name is a website's address on the Internet.
➢ Domain names are used in URLs to identify to which server belong a specific webpage.
➢ The domain name consists of a hierarchical sequence of names (labels) separated by periods
(dots) and ending with an extension.

URL :- URL stands for Uniform Resource Locator. A URL is nothing more than the address of a
given unique resource on the Web or address of a website. The URL is an address that matches
users to a specific resource online, such as webpage. Example- http://www.kvsangathan.nic.in

WWW : The World Wide WEB (WWW), commonly known as the ‘Web’. It is an information system
where all the web resources are identified by Uniform Resource Locator (URL). Tim Berners- Lee
invented the WWW in 1989. He wrote the first web browser in 1990. The World Wide WEB
(WWW) or ‘Web’ is a collection of WebPages found over the internet. Web browser uses the
internet to access the ‘Web’.

Application of Internet Web 2.0 : The term web 2.0 is used to refer to a new generation of websites
that are supposed to let people to publish and share information online. It aims to encourage the
sharing of information and views, creativity that can be consume by the other users. E.g: Youtube

The Main characteristics of web 2.0 are:

• Makes web more interactive through online social media web- based forums,
communities, social networking sites.
• It is a website design and development world which aim to encourage sharing of
information and views, creativity and user interactivity between the users.
• Video sharing possible in the websites
Web 3.0:

➢ It refers to the 3rd Generation of web where user will interact by using artificial intelligence
and with 3-D portals. Web 3.0 supports semantic web which improves web technologies to
create, connect and share content through the intelligent search and the analysis based on the
meaning of the words, instead of on the keywords and numbers.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 65


e-mail:

➢ email (or e-mail) is defined as the transmission of messages over communications networks.
Typically the messages are notes entered from keyboard and sent over internet using
computer or mobile.
Chat : Chat may refer to any kind of communication over the Internet that offers a real-time
transmission of text messages from sender to receiver. Chat messages are generally short in
order to enable other participants to respond quickly.

VoIP :- Voice over Internet Protocol (VoIP), is a technology that allows you to make voice calls
using a broadband Internet connection instead of a regular (or analog) phone line. VoIP services
convert your voice into a digital signal that travels over the Internet. If you are calling a regular
phone number, the signal is converted to a regular telephone signal before it reaches the
destination. VoIP can allow you to make a call directly from a computer. Examples of Voip:-
Whatsapp, Skype, Google Chat etc.

Advantage of VoIP:
✓ Save a lot of money.
✓ More than two people can communicate or speak.
✓ Supports great audio transfer.
✓ Provide conferencing facility.
✓ More than voice (can transfer text, image, video along with voice).
Disadvantages of Voip:
✓ Reliable Internet connection required.
✓ No location tracking for emergency calls.
Website:- a website is a group of web pages, containing text, images and all types of multi-media
files.

Web Server: - A web server is a computer that stores web server software and a website's
component files (e.g. HTML documents, images, CSS style sheets, and JavaScript files).

The basic objective of the web server is to store, process and deliver web pages to the users using Hypertext
Transfer Protocol (HTTP). Apart from HTTP, a web server also supports SMTP (Simple Mail transfer Protocol)
and FTP (File Transfer Protocol) protocol for e-mailing, for file transfer and storage.

When client sends request for a web page, the web server search for the requested page if
requested page is found then it will send it to client with an HTTP response. If the requested web
page is not found, web server will the send an HTTP response: Error 404 Not found.

Web Hosting :- Web hosting is an online service that enables you to publish your website or web
application on the internet. When you sign up for a hosting service, you basically rent some space on
a server on which you can store all the files and data necessary for your website to work properly.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 66


A server is a physical computer that runs without any interruption so that your website is available
all the time for anyone who wants to see it.

Types of Web Hosting:

One can use the space One server acts as


allotted to him to host multiple servers for
websites for other third multiple websites.
Web Browser :- A web browser, or simply "browser," is an application used to access and view
websites. Common web browsers include Microsoft Internet Explorer, Google Chrome, Mozilla
Firefox, and Apple Safari.

Plug-ins: - a plug-in (or plugin, add-in, add-on) is a software component that adds a specific feature
to an existing computer program. When a program supports plug-ins, it enables customization.
Plug-ins are commonly used in Internet browsers but also can be utilized in numerous other
types of application

Add-ons (in terms of H/W): An Add-on is either a hardware unit that can be added to a computer to
increase the capabilities or a program unit that enhances primary program. Some manufacturers and
software developers use the term add-on.

Cookies: - cookies are small files which are stored on a user’s computer and contains
information like which Web pages visited in the past, logging details Password etc. They are
designed to hold a modest amount of data specific to a particular client and website and can be
accessed by the web server or the client computer.

Chapter Practice:
Very Short Answer Question (for 1 Mark)

Q.1 _____________ Topology is based on a central network which acts as hub.


Ans. Star
Q.2 _________ is larger than LAN and smaller than WAN
Ans. MAN
Q.3 A computer network can categorized by their
Ans. Size
Q.4 __________ connects multiple computer networking devices together
Ans. Hub

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 67


Q.5 Gateway is network device used to connect two or more _________ netoworks.
Ans. dissimilar
Q.6 In ________ topology, single cable is used to connect all the workstations.
Ans. Bus
Q.7 Repeaters work on the __________ layer.
Ans. Physical
Q.8 __________ network is owned by a single organization.
Ans. LAN (Local Area Network)
Q.9 What is a purpose of server in a network?
Ans. A Server manages network resources in a network.
Q.10 What is the purpose of switch in a network?
Ans. Switch is used to connect multiple LANs together.
Q.11 What is the name of the network topology in which each node is connected independently
using a switch?
Ans. Star Topology.
Q.12 Expand WAN and MAN
Ans.
WAN – Wide Area Network
MAN – Metropolitan Area Network
Q.13 Two students in the same class sitting inside the same room have connected their laptops
using Bluetooth for working on a group presentation.
Ans, PAN (Personal Area Network)
Q.14 Which type of network out of LAN, PAN and MAN is formed, when you connect two mobile
using Bluetooth to transfer a video?
Ans. PAN (Personal Area Network)
Q.15 Which device is used to connect all computers inside a lab?
Ans. Hub or Switch
Q.16 Expad the following
(i) LAN (ii) PAN
Ans.
LAN- Local Area Network
PAN- Personal Area Network.
Q.17 Internet is an example of which topology:
Star, Mesh , Tree, Bus
Ans. Mesh
Q.18 __________ Network device is a broadcast device.
Ans. Hub
Q.19 Which of the following is not a Geographically type of network?
LAN, MAN, PAN, TAN, Wi Max, WAN
Ans. TAN
Q.20 To prevent unauthorized access to and / or from the network, a system known as
____________, can be implemented by hardware and / or software.
Ans. Firewall
Q.21 _________ is computer network i.e., network of networks.
Ans. Internet
Q.22 __________ is a unique identifier used to locate a resource on the Internet.
Ans. URL
Q.23 World Wide Web was begun in 1989 by _____________.
Ans. Tim Beners-Lee
Q.24 __________ field indicates the purpose of e-mail.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 68


Ans. Subject
Q.25 __________symbol separates the user from the domain.
Ans. @
Q.26 ___________ is the hub of Internet chatting.
Ans. Chat room
Q.27 VoIP stands for __________
Ans. Voice over Internet Protocol
Q.28 A Website is a collection of _____________.
Ans. Web Pages.
Q.29 Write one example of each of URL and IP address.
Ans.
URL : https://www.cbse.nic.in/welcome.html
IP address : 122.176.185.219
Q.30 How is a domain name different from a URL
Ans. Domain names are used in URLs to identify particular web servers.
For example
In the URL : https://www.cbse.nic.in/welcome.html the domain name is www.cbse.nic.in

Short Answer Question (for 2 Mark)

Q1. Differtiate between IP Address vs MAC Address?


Ans:
IP Address MAC Address
It is of 4 bytes It is of 6 bytes
Represented by decimal number Represented by hexadecimal number
It is logical address It is physical address
It is variable address It is fixed address
It is assigned only when a device is It is assigned by manufacturer of the card
connected
Command to to know
network
the IP address is irrespective
Command toofknowconnectivity
the IP address is
ipconfig ipconfig/all
Q.2 What is a server?
Ans. A server is a computer or system that provides resources, data, services or programs to
other computers, known as clients over a network. A server may be designed to do a single
task such as mail server, which accepts and store email and then provides it to a requesting
client.
Q3. Define the following terms.
(a) ARPANET (b) ISP (c) URL
Ans.
(a) ARPANET stands for Advanced Research Projects Agency Network.
(b) ISP stands for Internet Service Provider
(c) URL stands for Uniform Resource Locator
Q4. Define home page. Give two advantages of home page.
Ans. A home page is the first page of a website. Two advantages of home page are as follows:
(i) It helps viewers to find out what they can find on that site.
(ii) Publicity of an individual or a community.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 69


Q5. Sahil, a Class X student, has just started understanding the basics of Internet and web
technologies. He is a bit confused in between the terms “World Wide Web” and “Internet”.
Help him in understanding both the terms with the help of suitable examples of each.
Ans. World Wide Web is a set of programs, standards and protocols that allows the multimedia and
hypertext files to be created, displayed and linked on the Internet. e.g. www.microsoft.com,
www.amazon.com, etc.
Internet is a computer-based world wide communications network, which is composed of large
number of smaller interconnected networks. e.g. Web, E-mails, Social media, etc. While
Internet is a collection of computers or networking devices connected together; WWW is a
collection of documents, linked via special links called hyperlinks. WWW forms a large part of
Internet but is not the Internet.

Q6. Ruhani wants to edit some privacy settings of her browser. How can she accomplish her task?
Ans. She can accomplish her task by performing following steps
Step 1 Open your web browser.
Step 2 Open browser settings.
Step 3 Look for Privacy and Security settings. If not directly
found, click on Advanced settings.
Step 4 After reaching Privacy and Security settings she can
edit their setting.
Q7. What is the difference between Website and Webpage

Ans:

Website Webpage
1. A collection of web pages which are grouped A document which can be displayed in a
together and usually connected together in web browser such as Firefox, Google
various ways, Often called a "web site" or simply Chrome, Opera, Microsoft Internet
a "site." Explorer etc.
2. Has content about various entity. Has content about single entity.
3. More development time is required. Less development time is required.
4. Website address does not depend on Webpage Webpage address depends on Website
address. address.

Q8. What is the difference between Static and Dynamic webpage?

Ans:

Static Webpage Dynamic Webpage


The static web pages display the same content In the dynamic Web pages, the page
each time when someone visits it. content changes according to the user.
It takes less time to load over internet. Dynamic web pages take more time while
loading.
No Database used. A database is used in at the server end in a
dynamic web page.
Changes rarely. Changes frequently.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 70


Q.9 Define Voice over Internet Protocol (VoIP). Also, explain its advantages.
Ans. VoIP is an IP telephony term for a set of facilities used to manage the delivery of voice
information over Internet. It enables a user to make cheap telephone calls over a broadband
Internet connection, instead of using a regular telephone service. A major advantage of VoIP is
that avoids the tolls charged by ordinary telephone service. A user can make a call locally or in
other parts of US or Canada, or anywhere else in the world, eliminating long distance fees by
using a VoIP service. The concept of VoIP is used in wireless LAN networks and sometimes
referred to as WVoIP, VoFI, VoWi-Fi and Wi-Fi VoIP.
Advantages of VoIP
(i) The biggest single advantage of VoIP has over standard telephone systems is low cost.
(ii) Using services such as true VoIP, subscribers can call one another at no cost to other party.
(iii) Routing phone calls over existing data networks eliminate the need for separate voice and
data networks.
(iv) The ability to transmit more than one telephone call over a single broadband connection.
(v) VoIP consists advance telephone features, e.g. call routing, screen POP and IVR.

Q10. What is website? Also, write its components.


Ans. A website is a collection of digital documents, primarily HTML files, that are linked together and
that exist on the web under the same domain. A website displays related information on a
specific topic. Each website is accessed by its own address known as URL (Uniform Resource
Locator).
Components of a website
(i) Web host Group of linked web pages qualify to be called a website only when hosted on a web
server.
(ii) Address This is the address of the website (also called URL of the website).
(iii) Home page Every website has a home page. It is the first web page that appears when
viewers go to a website.
(iv) Design It is the overall look and feel the website has a result of proper use and integration
elements like nevigation menus, layout etc.
(v) Content All the web pages contained in the website together make up the content of the
website.
(vi) Navigation Structure The navigation structure of a website is order of the pages, the
collection of what
Q11. XYZ consultancy is planning to link its branch office in Delhi to its head office in London. Write
one way to connect. What type of network (out of LAN/WAN/MAN) will be formed.
Ans. (i) Satellite communication
(iii) WAN (Wide Area Network)

Q12.What is the differences between LAN and WAN ?


Ans.
LAN (Local Area Network) WAN (Wide Area Network)
(i) It is owned by a private organization. It is owned by multiple Organizations.
(ii) Diameter of less than a few kms. Span entire countries.
Q13. What is the difference between PAN and LAN?
Ans.
PAN LAN
(i) PAN stands for Personal Area Network LAN stands for Local Area Network
(ii) It spans a few meters It Spans upto a km.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 71


Long Answer Question (for 3/4 Mark)

Q.1 ABC Pvt. Ltd. Is setting up the network in the Bengaluru. There are four departments named
as Market, Finance, Legal and Sales.
Distance between various Departments building is as follows :

From To Distance
Market Finance 80 mt
Market Legal 180 mt
Market Sales 100 mt
Legal Sales 150 mt
Legal Finance 100 mt
Fianance Sales 50 mt

Number of computers in the buildings :


Building No. of Computers
Market 20
Legal 10
Finance 08
Sales 42

(i) Suggest a cable layout of connections between the departments building and specify the
topology.
(ii) Suggest the most suitable building to place server by giving suitable reason.
(iii) Suggest the placement of (i) modem (ii) hub/switch in the network.
(iv) The organization is planning to link its sales counter situated in various part of the same city,
which type of network out of LAN, WAN, MAN will be formed? Justify your answer.

Ans. (i)

Star topology should be used.


(ii) Sales is the most suitable building to place the server because it has maximum number of
computers.
(iii) Each Building should have hub/switch and modem in case internal connection is required.
(iv) MAN (Metropolian Area Network) as this network can be carried out in a city network.

Q.2 Delhi Public School in Meerut is starting up the network between its different wings. There
are four building named as S, J, A and H. The distance between various buildings is as follows :

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 72


From To Distance
A S 200 m
A J 150 m
A H 50 m
S J 250 m
S H 350 m
J H 350 m
Number of computers in the buildings :
Building No. of Computers
S 130
J 80
A 160
H 50

(i) Suggest the cable layout of connections between the buildings.


(ii) Suggest the most suitable place (i.e. building) to house the server of this school,
provide a suitable reason.
(iii) Suggest the placement of the following devices with justification
• Repeater
• Hub/Switch
(iv) The organization also has enquiry office in another city about 50-60 km away in
hilly region. Suggest the suitable transmission media to inter-connect school and enquiry
office out of the following :
• Fibre optic cable.
• Micro wave.
• Radio wave.
Ans
(i)

Star Topology

(ii) Server can be placed in the A building as it has the maximum number of computers
(iii) Repeater can be placed between A and S buildings as the distance is more than100 m
(iv) Radio waves can be used in hilly region as they can travel through obstacles.

Q.3 Rovenza Communication International (RCI) is an online corporate training provider


company for IT related course. The company is setting up their new campus in Kolkata. You as a
network expert have to study the physical locations of various blocks ad the number of computers to
be installed. In the planning phase, provide the best possible answers for the queries (i) to (iv) raised
by them.

Block to block distance (in meters)

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 73


From To Distance
Administrative Finances 60
Administrative Faculty studio 120
Finances Faculty studio 70

Expected computers to be installed in each block


Building No. of Computers
Administrative 20
Finances 40
Faculty studio 120

(i) Suggest the most appropriate block, where RCI should plan to install the server.
(ii) Suggest the most appropriate block to block cable layout to connect all three blocks for
efficient communication.
(iii) Which type of network out of the following is formed by connecting the computers of these
three blocks A. LAN B.MAN C.WAN
(iv) Which wirless channel out of the following should be opted by RCI to connect to students
from all over the world:
A. Infrared B.Microwave C. Staellite.
Ans.
(i) Faculty Studio.
(ii)

(iv) LAN (Local Area Network)


(v) Satellite connection

Q.4 XYZ is professional consultancy company. The company is planning to set up their new
offices in India with its hub at Pune. As a network adviser, you have to understand their requirement
and suggest them to best available solutions. Their queries are mentioned as (i) to (iv) below :
Physical Location of the blocks of XYZ

Block to block distance (in meters):


From To Distance
Human Resource Conference 110
Human Resource Finance 40

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 74


Conference Finance 80

Expected number of computers to be installed in each block


Building No. of Computers
Huma Resource 25
Fianance 120
Confernce 90

(i) What will be the most appropriate block, where XYZ should plan to install their server?
(ii) Draw a block diagram showing cable layout to connect al the buildings in the most appropriate
manner for efficient communication.
(iii) What will be the best possible connectivity out of the following you will suggest to connect the
new setup of offices in Chennai with its London based office.
• Satellite link
• Infrared
• Ethernet Cable.
(iv) Which of the following device will be suggested by you to connect each computer in each of the
buildings?
• Switch
• Modem
• Gateway

Ans:
(i) Finance block because it has maximum number of computers.
(ii)

(iii) Satellite Link


(iv) Switch

Q.5 Uplifting skills Hub India is a knowledge and skill community which has an aim to uplift the
standard of knowledge and skills in the society. It is planning to setup its training centres in multiple
towns and villages in India with its head office in the nearest cities. They have created a model of
their network with a city a town and 3 villages as follows. As a network consultant, you have to
suggest the best network related solutions for their issues problems raised in (i) to (iv) keeping in
mind that distance between various location and given parameters.

Village 3 B-TOWN
B_HUB
Village 2
Village 1

Shortest distance between various location :

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 75


From To Distance
Village1 B-Town 2 km
Village2 B-Town 1.0 km
Village3 B-Town 1.5 km
Village 1 Village 2 3.5 km
Village 1 Village 3 4.5 km
Village 2 Village 3 2.5 km
A_City Head Office B_Hub 25 km

Number of computers installed at various locations are as follows:


Location No. of Computers
B_Town 120
Village1 15
Village2 10
Village3 15
A_City Head Office 06

Note:
• In Villages, there are community centres, in which one room has been given as training
centre to this organization to install computers.

• The organization has get financial support form the government and top IT companies.

(i) Suggest the most appropriate locations of the SEVER in the B_HUB out of 4 locations, to get
the best and effective connectivity. Justify your answer.
(ii) Suggest the best wired medium and draw the cable various locations with the B_HUB
(iii) Which hardware device will you suggest to connect all the computers within eact location of
B_HUB
(iv) Which service/protocol will be most helpful to conduct live interactions of experts from
Head_Office and people at all location of B_HUB?
Ans.
(i) B_TOWN can house the server as it has the maximum no. of computers.
(ii) Optical Fibre cable is the best for the star topology.

(iii) Switch
(iv) VoIP

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 76


CHAPTER-601
CBSE SAMPLE PAPER 2021-22(TERM-2)

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 77


KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 78
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 79
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 80
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 81
CBSE SAMPLE PAPER 2021-22(TERM-2)

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 82


KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 83
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 84
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 85
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 86
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 87
CHAPTER-7
PRACTICE PAPER-1(TERM-2)
Informatics Practices (065)
Class 12

Time: 02:00 Hrs Marks: 35


Instructions:
1. There are 16 questions in the question booklet.
2. Each question is compulsory.
3. The Question paper is divided into four sections - Section A containing 05 questions each
of 01 mark, Section B containing 05 questions each of 02 marks, Section C containing 04
questions each of 03 marks, Section D containing 02 questions each of 04 marks.
4. Options are available with the questions in Section D.

SECTION - A (01 MARK QUESTIONS)

QNo. Question Marks

1 Write the output of the following command? 1

select round(123.789,-2);

(a) 100 (b) 120

(c) 123.78 (d) 123.80

2 A website is a collection of 1

(a) Webpages (b) Webpages

(c) Webservers (d) Hyperlinks

3 Which of the following network devices is also known as intelligent hub? 1

(a) Router (b) Gateway

(c) Repeater (d) Switch

4 The protocols used to send and receive emails, respectively, are 1


(a) SMTP, MIME (b) SMTP, POP3

(c) POP3, SMTP (d) POP3, MIME

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 88


5 Which of the following SQL commands may output 24? 1

(a) select day(now());


(b) select now();
(c) select dayname(now());
(d) select month(now());

SECTION - B (02 MARK QUESTIONS)

6 Consider the string “Class 12 CS”. Write command to display: 2


(a) the position of string “CS” in the string “Class 12 CS”.
(b) Last six characters of the string “Class 12 CS”.

7 Explain the difference between where and having clauses in SQL with the 2
help of a suitable example.

8 Consider the below given Student table and answer the questions which 2
follow:

(a) What will be the output of


select sum(roll)+count(roll)+sum(marks)+count(marks) from student;
(b) Write command to update marks equal to 0 where roll number is NULL.
9 Given a decimal number 1905.675, write commands in SQL to 2
(a) round it off to the number 2000.
(b) round it off to 1 place after the decimal.
10 Anisha has been given the below given student table: 2

(a) How will she generate the following output using group by and having
statements?

(b) How will she update the student table to increase marks of all students

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 89


by 10% and obtain the following output?

SECTION - C (03 MARK QUESTIONS)

11 A Salesman relation is given below: 3

(a) Write SQL command to display the area-wise count of salesmen for
those areas who have more than 1 salesman.
(b) Write SQL command to find the total Sales.
(c) Write SQL command to display the Sname and Dojoin of the salesman
who has joined most recently.
12 How are aggregate functions different from other SQL functions? Ishita is 3
trying to find the max sales out of all the sales corresponding to Salesmen
having Delhi as address in the Salesman table given in Q11. Write two
different SQL queries (using group by and without using group by) to
perform this task.
13 Predict the output of below given SQL queries 3
a. select length(ltrim(" ABCD EFGH "));
b. select length(trim(" ABCD EFGH "));
c. select power(instr(lower('A@123'),'2'),instr(lower('A@123'),'3'));
14 Differentiate between the following 3
a. static and dynamic web page
b. website and webpage
SECTION - D (04 MARK QUESTIONS)

15 Write the SQL commands which will perform the following operations? 4
a. To display the starting position of your last name (lname) from the
whole name (name).
b. To display dayname, month name and year from today’s date.
c. To display the remainder on dividing 3 raised to power 5 by 5.
d. To display ‘I am here’ in lower as well as uppercase.

OR
Consider the table Salesman with the given data

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 90


Write SQL queries using function to perform the following operation:
a. Display Scode and Sales after rounding off the Sales to 1 decimal
place.
b. Display the dayname from Dojoin of Salesman.
c. Display the position of occurrence of “a” in the Sname.
d. Display three characters from Sname starting from the second
character for those salesmen whose name ends with ‘t’.
16 Indian School, in Mumbai is starting up the network between its different 4
wings. There are four Buildings named as SENIOR, JUNIOR, ADMIN and
HOSTEL. The distance between various buildings is as follows:

The number of computers is as follow:

a. Suggest the cable layout of connections between the buildings.


b. Suggest the most suitable place (i.e., building) to house the server
of this school, provide a suitable reason.
c. Suggest the placement of the following devices with justification.
Repeater, Hub/Switch
d. The organisation also has inquiry office in another city about 100 kms
away in hilly region. Suggest the suitable transmission media to
interconnect to school and inquiry office out of the following :
Fiber optic cable, Microwave, Radiowave

OR
Trine Tech Corporation (TTC) is a professional consultancy company.
The company is planning to set up their new offices in India with its hub at
Hyderabad. As a network adviser, you have to understand their
requirements and suggest them the best available solutions. Their queries
are mentioned as (a) to (d) below. TTC is having three blocks, namely
Human Resource Block, Conference Block and Finance Block.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 91


Distance between blocks:
Block (From) Block (To) Distance Human Resource Conference
110
Human Resource Finance 40
Conference Finance 80
Also, the number of computers to be installed in each block are: Block
Computers
Human Resource 25
Finance 120
Conference 90
a. What will be the most appropriate block, where TTC should plan to
install their server?
b. Draw a block to cable layout to connect all the buildings in the most
appropriate manner for efficient communication.
c. What will be the best possible connectivity out of the following, you
will suggest to connect the new setup of offices in Bangalore with its
London based office: Satellite Link, Infrared, Ethernet Cable
d. Which of the following device will be suggested by you to connect
each computer in each of the buildings: Switch, Modem, Gateway

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 92


PRACTICE PAPER – 2 (TERM-2)
2022
Informatics Practices (065)
Class 12

Time: 02:00 Hrs Marks: 35

Instructions:
1. There are 16 questions in the question booklet.
2. Each question is compulsory.
3. The Question paper is divided into four sections - Section A containing 05 questions each
of 01 mark, Section B containing 05 questions each of 02 marks, Section C containing 04
questions each of 03 marks, Section D containing 02 questions each of 04 marks.
4. Options are available with the questions in Section D.

SECTION - A (01 MARK QUESTIONS)

QNo. Question Marks

1 Write the output of the following command? 1

select truncate(123.789,-2);

(a) 120 (b) 130

(c) 123.78 (d) 100

2 Which of the following communication mediums will offer the highest 1


bandwidth?
(a) Optical Fibre (b) Shielded Twisted Pair

(c) Unshielded Twisted Pair (d) Coaxial cable

3 For n devices in a network, what is the number of cable links required for a 1
mesh topology?
(a) n*2 (b) n*(n-1)

(c) (n-1)/2 (d) n*(n-1)/2

4 Which of the following protocols is used in real time internet based 1


communication?
(a) VoIP (b) SMTP

(c) POP3 (d) MIME

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 93


5 If on ‘1990-01-22', it was Monday, what will be the output of following SQL 1
command?
select dayname('1990-01-22')+1;

(a) Error
(b) 1
(c) 7
(d) Monday

SECTION - B (02 MARK QUESTIONS)

6 Consider the string “ PYTHON LANGUAGE ”. Write command to display: 2


(a) the length of the string after trimming spaces from the beginning and
end.
(b)Position of string “LA” after trimming only beginning spaces from the
string “ PYTHON LANGUAGE ”.

7 Given a table Orders (oid, cuid, item), Radhika applies the following 2
command to find cuid of those customers who have two or more than two
orders.
select cuid,count(*) from orders where count(*)>=2; However, the code
gives an error. Explain the reason and write correct code to achieve the
desired task.

8 Akash writes the following commands for a student table having attributes 2
roll, name, age and class.
Command1: select count(*) from student
Command2: select count(age) from student.
He gets the output 10 for the first command but gets an output 8 for the
second command. Explain the reason behind this difference.

9 Given a number n, write commands in SQL to 2


(a) compute cube of this number using SQL function.
(b) compute remainder on division of n by another number m using SQL
function.

10 Anita has been given the below given orders table: 2

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 94


(a) How will she generate the following output using group by and aggregate
functions wherein the count of items for cuid are arranged in descending
order?

(b) How will she count the number of distinct items in the orders table?
SECTION - C (03 MARK QUESTIONS)

11 A student relation is given below: 3

(a) Write SQL command to display the class-wise count of students for
those classes who have more than 2 students.
(b) Write an SQL command to find the average marks for class XI and
class XII students.
(c) Write an SQL command to display the name and DOB of the youngest
student.
12 Give suitable examples to explain the role of % and _ characters for pattern 3
matching in SQL.

13 Predict the output of below given SQL queries 3


a. select power(instr('abcd412','1'),3);
b. select substr(lower('ABC 123'),1,3)
c. select power(instr(upper('A@123'),'1'),instr(upper('A@123'),'2'));

14 Differentiate between the following 3


a. LAN and WAN
b. SMTP and POP3

SECTION - D (04 MARK QUESTIONS)

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 95


15 Write the SQL commands which will perform the following operations? 4
a. To display the position of space character in your name (myname).
b. To display day, month and year from today’s date.
c. To compute 5 raised to the power remainder on dividing 15 by 4.
d. To display the leftmost as well as the rightmost character of the string
‘PYTHON’.
OR
Consider the table Salesman with the given data

Write SQL queries using function to perform the following operation:


a. Display maximum sales for each area.
b. Display the month name from Dojoin of Salesman.
c. Display those addresses which anywhere contain ‘i’.
d. Display two characters from Sname starting from the first character
for those salesmen who belong to Delhi.
16 ABC is an online corporate training provider company for IT related courses. 4
The company is setting up their new campus in Kolkata. You as a network
expert have to study the physical locations of various blocks and the
number of computers to be installed. In the planning phase, provide the best
possible answers for the queries (i) to (iv) raised by them.
Distance between blocks:

a. Suggest the most appropriate block, where ABC should plan to install
the server.
b. Suggest the most appropriate block to block cable layout to connect
all three blocks for efficient communication.
c. Which type of network out of the following is formed by connecting
the computers of these three blocks? LAN, MAN, WAN

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 96


d. Which wireless channel out of the following should be opted by ABC
to connect to students from all over the world? Infrared, Microwave,
Satellite.
OR
A company XYZ Enterprises has four blocks of buildings as shown:

Center to center distance between various blocks

B3 TO B1 40 M

B1 TO B2 50 M

B2 TO B4 15 M

B4 TO B3 150 M

B3 TO B2 115 M

B1 TO B4 90 M

Number of computers in each block :

B1 140

B2 20

B3 18

B4 30

Computers in each block are networked but blocks are not networked. The
company has now decided to connect the blocks also
a. Suggest the most appropriate topology for the connections between
the blocks.
b. The company wants internet accessibility in all the blocks. The
suitable and cost-effective technology for that would be .
c. Which device will you suggest for connecting all the computers
within each of their blocks?
d. The company is planning to link its head office situated in New
Delhi with the offices in hilly areas. Suggest a way to connect it
economically:

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 97


BIBLIOGRAPHY

This Students Support Material prepared with reference of following sources:

1. NCERT Text Book, Informatics Practices, Class XII

2. Arihant CBSE TERM-2(2022), Informatics Practices, Class XII

3. Student Support Material, KVS Raipur Region

4. Teachers WhatsApp group.

KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page No- 98

You might also like