You are on page 1of 11

REVISION - DATABASE CONCEPTS & SQL (30 Marks)

1. What are the following? Refer to ppt for the correct answers
a. Database
b. DBMS (with examples )
c. Table/ Relation
d. Tuple/ Rows/ Records
e. Fields/ Columns/ Attributes
f. Degree
g. Cardinality
h. Primary key
i. Candidate keys
j. Alternate keys
2. Full form of SQL, DDL, DML, DQL Refer to ppt for the correct answers
3. Classify the SQL commands into DML & DDL
a. Create database - DDL
b. Create table - DDL
c. Insert into - DML
d. Update - DML
e. Select - DML
f. Delete - DML
g. Drop table - DDL
h. Drop database - DDL
4. Name the SQL command for the following:
a. To list all existing databases
SHOW DATABASES;
b. To create a database XYZ
CREATE DATABASE XYZ;
c. To open database XYZ
USE XYZ;
d. To list all tables in the current database
SHOW TABLES;
e. To create a table
CREATE TABLE
f. To display the structure of a table
DESC

Page 1 of 11
g. To add a record in a table
INSERT INTO
h. To display records in a table
SELECT
i. To delete rows/records from a table
DELETE
j. To modify the existing data stored in a table
UPDATE
k. To delete a table ABC
DROP TABLE ABC;
l. To delete the database XYZ
DROP DATABASE XYZ;

5. Based on the table structure below, write a query to create a table


Student. Also, which command can be used to display its structure?

Field Type Null Key


ROLLNO INT(2) NO PRI
NAME VARCHAR(15) YES
DOB DATE YES
HEIGHT FLOAT YES

To create the table,


CREATE TABLE STUDENT
(ROLLNO INT PRIMARY KEY,
NAME VARCHAR(15),
DOB DATE,
HEIGHT FLOAT(5,1) ) ;

To display the table structure,


DESC STUDENT;

6. Consider the table STUDENT given below and answer the questions
given below.
Table: STUDENT
RollNo AdmNo Name Place DOB Height House Percent
1 1778 Dona Kochi 2004-01-20 160.5 Blue 89
2 2344 Amit Delhi 2006-09-22 170.0 Red 94
3 8766 Ben Goa 2005-05-17 167.9 Blue 79
Page 2 of 11
4 8355 Mary Goa 2006-01-29 155.4 Green 88
5 7899 Bony Kochi 2006-11-07 175.6 Yellow 85
6 1566 Kary Goa 2004-01-23 164.0 Red 96

a. What is the degree and cardinality of the above table?


DEGREE = 8 , CARDINALITY = 6
b. Identify the primary key, candidate keys and alternate keys in the
table
PRIMARY KEY - ROLLNO
CANDIDATE KEYS – ROLLNO, ADMNO
ALTERNATE KEY - ADMNO

7. Write an SQL query for the following on the basis of STUDENT table:
a. Insert the first record
INSERT INTO STUDENT
VALUES (1,1778, ‘Dona’, ‘Kochi’, ‘2004-01-20’, 160.5, ‘Blue’, 89) ;
b. Display details of all students
SELECT * FROM STUDENT;
c. Display details of all students in the ascending order of name
SELECT * FROM STUDENT ORDER BY NAME;
d. Display details of all students in the descending order of percent
SELECT * FROM STUDENT ORDER BY PERCENT DESC;
e. Display roll number, name and house of all students
SELECT ROLLNO, NAME, HOUSE FROM STUDENT;
f. Display details of all students from Goa
SELECT * FROM STUDENT WHERE PLACE = ‘GOA’;
g. Display the names of blue house students from Goa
SELECT * FROM STUDENT WHERE HOUSE= ‘BLUE’ AND PLACE =
‘GOA’;
h. Display the list of different places
SELECT DISTINCT PLACE FROM STUDENT;
i. Display all students whose height is above 165
SELECT NAME FROM STUDENT WHERE HEIGHT > 165;
j. Display all students whose name starts with B
SELECT NAME FROM STUDENT WHERE NAME LIKE ‘B%’ ;
k. Display all students whose name ends with Y
SELECT NAME FROM STUDENT WHERE NAME LIKE ‘%Y’ ;

Page 3 of 11
l. Display all students with N in their name
SELECT NAME FROM STUDENT WHERE NAME LIKE ‘%N%’ ;
m. Display all students with 3 letter name starting with B
SELECT NAME FROM STUDENT WHERE NAME LIKE ‘B_ _ ’ ;
n. Change the house of Amit to Yellow
UPDATE STUDENT
SET HOUSE = ‘YELLOW’
WHERE NAME = ‘AMIT’;
o. Increase the percentage by 2%
UPDATE STUDENT
SET PERCENTAGE = PERCENTAGE + PERCENTAGE*2/100 ;
p. Reduce the percent by 1%
UPDATE STUDENT
SET PERCENTAGE = PERCENTAGE - PERCENTAGE*1/100 ;
q. Increase the height of all students by 1
UPDATE STUDENT
SET HEIGHT = HEIGHT + 1 ;
r. Remove the student with admission number 8355
DELETE FROM STUDENT WHERE ADMNO=8355;

8. Predict the output of the SQL Queries based on the table below:
Table: STUDENT
RollNo AdmNo Name Place DOB Height House Percent
1 1778 Dona Kochi 2004-01-20 160.5 Blue 89
2 2344 Amit Delhi 2006-09-22 170.0 Red 94
3 8766 Ben Goa 2005-05-17 167.9 Blue 79
4 8355 Mary Goa 2006-01-29 155.4 Green 88
5 7899 Bony Kochi 2006-11-07 175.6 Yellow 85
6 1566 Kary Goa 2004-01-23 164.0 Red 96

a. SELECT * FROM STUDENT WHERE ADMNO IN (1778, 8766, 1566);

RollNo AdmNo Name Place DOB Height House Percent


1 1778 Dona Kochi 2004-01-20 160.5 Blue 89
3 8766 Ben Goa 2005-05-17 167.9 Blue 79
6 1566 Kary Goa 2004-01-23 164.0 Red 96

Page 4 of 11
b. SELECT * FROM STUDENT ORDER BY HEIGHT;

RollNo AdmNo Name Place DOB Height House Percent


4 8355 Mary Goa 2006-01-29 155.4 Green 88
1 1778 Dona Kochi 2004-01-20 160.5 Blue 89
6 1566 Kary Goa 2004-01-23 164.0 Red 96
3 8766 Ben Goa 2005-05-17 167.9 Blue 79
2 2344 Amit Delhi 2006-09-22 170.0 Red 94
5 7899 Bony Kochi 2006-11-07 175.6 Yellow 85

c. SELECT NAME, HEIGHT FROM STUDENT ORDER BY HEIGHT DESC;

Name Height
Bony 175.6
Amit 170.0
Ben 167.9
Kary 164.0
Dona 160.5
Mary 155.4

d. SELECT NAME FROM STUDENT WHERE PERCENT BETWEEN 85


AND 90;
Name
Dona
Mary
Bony

e. SELECT ADMNO, NAME FROM STUDENT WHERE ADMNO NOT IN


(1778, 8766, 1566, 7899);
AdmNo Name
2344 Amit
8355 Mary

f. SELECT DISTINCT HOUSE FROM STUDENT;


House
Blue
Red
Green
Yellow

Page 5 of 11
REVISION - PYTHON (30 Marks)

1. Predict the output of the code given below:


a. for i in range(50,61):
print(i)
Output :
50
51
52
53
54
55
56
57
58
59
60
b. for i in range(50,61):
if i%2 == 0: Correction in the question
print(i)
Output :
50
52
54
56
58
60
c. for i in range(50,61):
if i%2 == 0 and i%3 ==0: Correction in the question
print(i)
Output :
54
60
d. L = [22,33,44,55]
L1=[10,20,30]
L.append(189)
print(L)
L.extend(L1)
print(L)
L.insert(1,50)
print(len(L))
Page 6 of 11
print(L+L1)
print(L1*3)
Output :
[22,33,44,55,189]
[22,33,44,55,189,10,20,30]
9
[22,50,33,44,55,189,10,20,30,10,20,30]
[10,20,30,10,20,30,10,20,30]

e. L = [2,4,6,8,10,20,18,16,14]
L.pop()
print(L)
L.pop(2)
print(L)
L.remove(10)
print(L)
del L[5]
print(L)
del L[2:6]
print(L)
Output :
[2,4,6,8,10,20,18,16]
[2,4,8,10,20,18,16]
[2,4,8,20,18,16]
[2,4,8,20,18]
[8,20,18]

f. L = [2,4,6,8,10,20,18,16,4]
print(20 in L)
print(16 not in L)
print(L.index(8))
print(L.count(4))
print(L.reverse())
print(L)
print(L.sort())
print(L)
print(L.sort(reverse=True))
print(L)
print(max(L), min(L))

Page 7 of 11
Output:
True
False
3
2
None
[4,16,18,20,10,8,6,4,2]
None
[2,4,4,6,8,10,16,18,20]
None
[20,18,16,10,8,6,4,4,2]
20 2

g. L = [2,4,6,8,10,20,18,16,14]
print(L[2:7])
print(L[7:2:-1])
print(L[::])
print(L[::-1])
print(L[0], L[-1], L[3])
Output :
[6,8,10,20,18]
[16,18,20,10,8]
[2,4,6,8,10,20,18,16,14]
[14,16,18,20,10,8,6,4,2]
2 14 8

h. X={9:89, 4:90, 10:75, 20:33 }


print(X.items())
print(X.keys())
print(X.values())
Output :
dict_items([(9, 89), (4, 90), (10, 75), (20, 33)])
dict_keys([9, 4, 10, 20])
dict_values([89, 90, 75, 33])

i. X={ 9:89, 4:90, 10:75, 20:33 }


Y={10:100, 11:200, 12:300}
X.update(Y)
print(X)
print(Y)
print(X[4], X[20])

Page 8 of 11
print(9 in X)
print(90 in X)
Output :
{9: 89, 4: 90, 10: 100, 20: 33, 11: 200, 12: 300}
{10:100, 11:200, 12:300}
90 33
True
False

j. X={9:89, 4:90, 10:75, 20:33 }


print(X.get(10))
X[7]=60
X[9]=95
print(X)
X.clear()
print(X)
print(len(X))

Output :
75
{9:95, 4:90, 10:75, 20:33, 7:60 }
{}
0

Page 9 of 11
REVISION –
INTRODUCTION TO COMPUTER SYSTEM & EMERGING TRENDS
(10 Marks)

1. What are the following? Refer to ppt for the correct answers
a. Main memory or Primary memory or RAM
b. Auxiliary memory or Secondary memory
c. Hard copy
d. Soft copy
e. Data Recovery
f. Bit
g. Byte
h. Nibble
i. Artificial intelligence
j. Augmented Reality
k. Virtual Reality
l. Robotics
m. Big Data
n. IOT
o. Sensors
p. Cloud Computing
q. Grid computing
r. Blockchain technology

2. Name the following: Refer to ppt for the correct answers


a. Any 2 examples of hardware
b. 3 parts of CPU
c. 2 types of computer memory
d. The elementary unit of memory
e. 2 main types of software
f. 2 types of Application softwares
g. 2 examples of machine learning
h. 2 applications using NLP
i. Any 4 characteristics of Big Data
j. Any 3 Cloud Services

Page 10 of 11
Page 11 of 11

You might also like