First Terms QL QN
First Terms QL QN
6) All the attributes that can be used to uniquely identify the tuples in the relation (can serve
as a primary key) is called the _________.
8) A result set is extracted from the database using the cursor object (that has been already
created) by giving the following statement.
Mydata=cursor.fetchone()
(b) What will be the datatype of Mydata object after the given command is executed?
9) Which command is given to save the changes permanently in the database after performing
update and delete queries in interface.
10) A resultset is extracted from the database using the cursor object(that has been
already created) by giving the following statement.
Myobject.fetchmany(5)
(a) How many records will be returned by fetchmany() method?
(b) What will be the data type of Myobject after the given command is executed?
11) Consider the table CLUB given below and write the output of the SQL queries
that follow:
(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE GENDER = "MALE" AND
PAY BETWEEN 1000 AND 1200;
12)
13)
Sartaj, now wants to display the records of students whose fee is more than 5000. Help Sartaj
to write the program in Python.
14) Write the outputs of the SQL queries (i) to (iii) based on the relations Teacher and
Placement given below:
(i) SELECT Department, avg(salary) FROM Teacher GROUP BY Department;
15) Navdeep creates a table RESULT with a set of records to maintain the marks secured by
students in Sem 1, Sem2, Sem3 and their division. After creation of the table, he has entered
data of 7 students in the table.
Table: RESULT
Based on the data given above answer the following questions:
i. Identify the most appropriate column, which can be considered as Primary key.
ii. If two columns are added and 2 rows are deleted from the table result, what will be the
new degree and cardinality of the above table?
iii. Write the statements to: a. Insert the following record into the table – Roll No- 108,
NameAadit, Sem1- 470, Sem2-444, Sem3-475, Div – I. b. Increase the SEM2 marks of the
students by 3% whose name begins with ‘N’.
iv) Write the statements to: a. Delete the record of students securing IV division. b. Add a
column REMARKS in the table with datatype as varchar with 50 characters
16)
Write SQL queries for the following:
(i) Display product name and brand name from the tables PRODUCT and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending order of rating.
17) Write SQL queries for (i) to (v), which are based on the table: SCHOOL and ADMIN