0% found this document useful (0 votes)
50 views

Sample Paper Ip pt2 Answer

Uploaded by

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

Sample Paper Ip pt2 Answer

Uploaded by

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

KENDRIYA VIDYALAYA SANGATHAN SAMPLE PAPER

CLASS XI INFORMATICS PRACTICES


PERIODIC TEST - 2 EXAMINATION 2021-22
Time Duration: 90 minutes Maximum Marks: 40
----------------------------------------------------------------------------------------------------------------------------------
General Instructions
1. This question paper is divided into three sections A,B and C
2. Section A is of 16 marks
3. Section B is of 12 marks
4. Section C is of 12 marks
SECTION ‘A’

1. Consider a table ‘emp’ as given below. 8

empno ename job mgr hiredate sal comm deptno


7369 SMITH CLERK 7902 1993-06-13 8000.00 0.00 20
7499 ALLEN SALESMAN 7698 1998-08-15 16000.00 300.00 30
7521 WARD SALESMAN 7698 1996-03-26 12500.00 500.00 30
7566 JONES MANAGER 7839 1995-10-31 29750.00 20
7698 BLAKE MANAGER 7839 1992-06-11 28500.00 30
7782 CLARK MANAGER 7839 1993-05-14 24500.00 10
7788 SCOTT ANALYST 7566 1996-03-05 30000.00 20
7839 KING PRESIDENT 1990-06-09 50000.00 0.00 10
7844 TURNER SALESMAN 7698 1995-06-04 15000.00 0.00 30
7876 ADAMS CLERK 7788 1999-06-04 11000.00 20
7900 JAMES CLERK 7698 2000-06-23 9500.00 30
7934 MILLER CLERK 7782 2000-01-21 13000.00 10
7902 FORD ANALYST 7566 1997-12-05 30000.00 20
7654 MARTIN SALESMAN 7698 1998-12-05 12500.00 1400.00 30

Write SQL queries for the following


i) Display all the records from ‘emp’ table.
ii) Display ‘empno’ and ‘ename’ of all employees from table ‘emp’
iii) Display ename, sal and sal added with comm from table ‘emp’
iv) Write a query to display employee name, salary, and department no who are not
getting commission from table ‘emp’.
v) List all department numbers in ‘emp’ table
vi) List the details of those employees who have names containing four characters
(letters).
vii) List the details of all employees whose annual salary is between 25000 – 40000.
viii) Show the names of all employees in alphabetical order.

Ans i) SELECT * FROM EMP;


ii) SELECT EMPNO,ENAME FROM EMP;
iii) SELECT ENAME,SAL, SAL+COMM FROM EMP;
iv) SELECT ENAME,SAL,DEPTNO FROM EMP WHERE COMM IS NULL;
v) SELECT DEPTNO FROM EMP;
vi) SELECT * FROM EMP WHERE ENAME LIKE '_ _ _ _ ';
vii) SELECT * FROM EMP WHERE SAL BETWEEN 25000 AND 40000
viii) SELECT ENAME FROM EMP ORDER BY ENAME;

2. Differentiate between DDL and DML commands. 2

1
Sr. No. Key DDL DML

Stands for DDL stands for Data Definition DML stands for Data Manipulation
1
Language. Language.

Usage DDL statements are used to create DML statement is used to insert,
2 database, schema, constraints, users, update or delete the records.
tables etc.

Commands CREATE, DROP, RENAME and INSERT, UPDATE and DELETE.


3
ALTER.

3. Write commands for the following 2


i) To create a database ‘INVENTORY’.
ii) To remove a database ‘STORE’.
iii) To see the list of databases.
iv) To set ‘SCHOOL’ as current database.

i) CREATE DATABASE INVENTORY;


ii) DROP DATABASE STORE;
iii) SHOW DATABASES;
iv) USE SCHOOL;

4. Consider the following table ‘BOOK’ and write output of the given queries 2

BookID Title Author Price


1111 VB John 500
2222 Java Ram 200
3333 Python Naresh 300
4444 SQL Mukesh 600
i) SELECT SUM(PRICE) FROM BOOK WHERE PRICE <400;
ii) SELECT MIN(PRICE) FROM BOOK;
iii) SELECT MAX(PRICE) FROM BOOK;
iv) SELECT AVG(PRICE) FROM BOOK;

Ans i) SUM(PRICE)
500
ii) MIN(PRICE)
200
iii) MAX(PRICE)
600
iv) AVG(PRICE)
400

5. Consider the following table ‘CITY’ and write output of the given queries 2

CITYCODE CITYNAME
200 Jabalpur
110 Anuppur
275 Chhindwara
230 Balaghat
174 Dewas
i) SELECT * FROM CITY ORDER BY CITYNAME;
2
ii) SELECT * FROM CITY ORDER BY CITYCODE DESC;

i)
CITYCODE CITYNAME

110 Anuppur
230 Balaghat
275 Chhindwara
174 Dewas
200 Jabalpur

ii)
CITYCODE CITYNAME

275 Chhindwara
230 Balaghat
200 Jabalpur
174 Dewas
110 Anuppur

SECTION ‘B’
6. Differentiate between 6
a) Primary Key and Foreign Key
b) Degree and Cardinality of a relation
c) NOT NULL constraint and UNIQUE constraint

Ans a) A primary key is a column or a set of columns in a table whose values uniquely identify a row in
the table. ... A foreign key is a column or a set of columns in a table whose values correspond to
the values of the primary key in another table.

Primary Key never accepts null values whereas foreign key may accept multiple null values.

You can have only a single primary key in a table while you can have multiple foreign keys in a
table.

The value of the primary key can’t be removed from the parent table whereas the value of foreign
key value can be removed from the child table.
b) Degree is the number of attributes or columns present in a table. Cardinality is the number of
tuples or rows present in a table.

Degree of Patients table is 4 and Cardinality is 5


c) The NOT NULL constraint is used to ensure that a given column of a table is never assigned the
null value. Once a NOT NULL constraint has been defined for a particular column, any insert or
update operation that attempts to place a null value in that column will fail.For example empid in
emp table.
The UNIQUE constraint ensures that all values in a column are different. The UNIQUE Constraint
prevents two records from having identical values in a column. For example, email addresses of
users in the users table

3
7. Write SQL command to create a table ‘TEACHER’ with the following specifications 3

Name of Attributes Data Type Size Constraint


TeacherID INT 5 Primary Key
TName VARCHAR 30 Not Null
Age INT 2
Department VARCHAR 30
Salary FLOAT

Ans: CREATE TABLE TEACHER


(
TeacherID int(5) primary key,
TName varchar(30) NOT NULL,
Age int(2),
Department varchar(30),
Salary float
);
8. Consider a table ‘ITEM’ with the attributes (ItemCode, ItemName). Write SQL command 3
to:
i) Add new column ‘ItemPrice’ with data type ‘int’.
ii) Show a description of table ‘ITEM’
iii) Remove the column ‘ItemName’.

Ans:
i) ALTER TABLE ITEM ADD(ItemPrice int);
ii) DESCRIBE ITEM
iii) ALTER TABLE ITEM DROP COLUMN ItemName;

SECTION ‘C’
9. Differentiate between 4
i) DROP TABLE and DELETE command in SQL
ii) CHAR and VARCHAR data type in SQL

Ans i) DELETE is used to delete one or several rows from the table.
DROP TABLE would remove the entire table from the database
DELETE is a DML command
DROP is a DDL command
ii) CHAR Datatype:
It is a datatype in SQL which is used to store character string of fixed length specified. If the length
of string is less than set or fixed length then it is padded with extra blank spaces so that its length
became equal to the set length. Storage size of CHAR datatype is of n bytes(set length). We should
use this datatype when we expect the data values in a column are of same length.

VARCHAR Datatype:
It is a datatype in SQL which is used to store character string of variable length but maximum of
set length specified. If the length of string is less than set or fixed length then it will store as it is
without padded with extra blank spaces. Storage size of VARCHAR datatype is equal to the actual
length of the entered string in bytes. We should use this datatype when we expect the data values
in a column are of variable length.

10. Explain 4
i) How can we insert a record in a table using SQL command? Give example.
ii) What is the use of ‘update’ command in SQL? Give example.
4
i) It is possible to write the INSERT INTO statement in two ways:

1. Specify both the column names and the values to be inserted:

INSERT INTO table_name (column1, column2, column3, ...)


VALUES (value1, value2, value3, ...);

2. If you are adding values for all the columns of the table, you do not need to specify the column
names in the SQL query. However, make sure the order of the values is in the same order as the
columns in the table. Here, the INSERT INTO syntax would be as follows:

INSERT INTO table_name


VALUES (value1, value2, value3, ...);

Example:
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');
ii) the UPDATE command is used to update existing rows in a table.

The following SQL statement updates the first customer (CustomerID = 1) with a new contact
person and a new city.

Example
UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE CustomerID = 1;

11. Consider the following table ‘CUSTOMER’ and write output of SQL queries for (i) to (iv) 4

CustomerID CustomerName CustomerAge CustomerCity


1234 Gagandeep 56 Durg
2345 Ravindra 48 Indore
4567 Hemraj 37 Balaghat
5678 Bhojpal 44 Jabalpur
6789 Shivram 61 Indore

(i) SELECT CustomerName, CustomerAge


FROM CUSTOMER
WHERE CustomerAge >45;

(ii) SELECT CustomerName, CustomerCity


FROM CUSTOMER
WHERE CustomerCity LIKE 'B%';

(iii) SELECT * FROM CUSTOMER WHERE CustomerCity='Indore';

(iv) SELECT distinct CustomerCity from CUSTOMER;

(i)
CustomerName CustomerAge
Gagandeep 56
Ravindra 48
Shivram 61

5
(ii)
CustomerName CustomerCity
Ravindra Indore
Shivram Indore

(iii)
CustomerID CustomerName CustomerAge CustomerCity
4567 Hemraj 37 Balaghat

(iv)
CustomerCity
Durg
Indore
Balaghat
Jabalpur

You might also like