CS Question Bank 2024
CS Question Bank 2024
OF PYTHON
CHAPTER 2 : FUNCTIONS
CHAPTER 6 : DATABASE
CONCEPTS
STATE THE GIVEN STATEMENTS ARE TRUE OR
Ans. Foreign Key
FALSE
Explanation: A foreign key is used to represent the
Q. 1. A relational database is a collection of tables.
relationship between two relations. A foreign key is an
Ans. True attribute whose value is derived from the primary key of
Q. 2. The degree of the relationship is number of another relation.
participating entities in a relationship. Q. 2. A RDBMS must comply with at least rules.
Ans. True Ans. 6
Explanation: The number of attributes in a Explanation: An RDBMS product has to satisfy at least
relation is called the Degree of the relation. For six of the 12 rules of Cod to be accepted as a full-fledged
example, a relation with five attributes is a RDBMS.
relation of degree 5. Q. 3. Tuple is used to refer to a ………..
Q. 3. Database Schema is the relation of a database. Ans. row
Ans. False Explanation: Each row of data in a relation (table) is
Explanation: Database Schema is the design of called a tuple. In a table with n columns, a tuple is a
a database. It is the skeleton of the database relationship between the n related values.
that represents the structure(table names and Q. 4. The minimal set of super key is known as
their fields/columns), the type of data each Ans. Candidate key
column can hold, constraints on the data to be Explanation: A candidate key is a minimal super key or a
stored (if any), and the relationships among the super key with no redundant attribute. It is called a
tables. minimal super key because we select a candidate key
Q. 4. Each tuple in a relation is distinct. from a set of super keys such that the selected candidate
Ans. True key is the minimum attribute required to uniquely
Explanation: A relation is defined as a set of identify the table.
tuples. By definition all the elements of a set are Q. 5. proposed the relational model.
distinct; hence, all the tuples in a relation must Ans. E.F. Codd
also be distinct. This means that no two tuples Explanation: In 1970 Edgar F. Codd, at the IBM San Jose
can have the same combination of values for all Research Laboratory, proposed a new data
their attributes. representation framework called the relational data
Q. 5. A collection of raw facts and figure is called model which established the fundamentals of the
information. relational database model.
Ans. False
Explanation: A collection of raw facts and
figure is called data.
FILL IN THE BLANKS
Q. 1. is a non-key attribute, whose values
are derived from the primary key of some other
table.
Explanation: A relational database consists of a collection of tables.
All data values are atomic. No repeating groups are allowed.
CHAPTER 7 : STRUCTURED QUERY
LANGUAGE (SQL)
Q. 1. Consider the table Teacher in which Tina wants to add two rows. For this, she wrote a
program in which some code is missing.
Write the following missing statements to complete the code:
(i) Which function will be filled in the blank at statement 2?
(ii) What should be come in the blank at the statement 1?
(iii) Which function will be filled in the blank at statement 3?
import mysql.connector mycon=mysql.connector.connect(host=”l
ocalhost”,User=”root”, passwd=”system”
,database=”test”)
cursor=con.cursor()
sql=”INSERT Teacher(T_Id,Fname,Lname, Hire_date, Salary,
Subject)
VALUSE (%s, %s, %s, %s, %s,%s)”,
#statement Line1
val =[(101, ‘Vibha’, ‘Bajpai’, ’12-
10-2021’, 27000, ‘Python’), (104,
‘Rekha’,‘Sharma’, ’01-01-2022’, 27000,
‘Math’)]
try:
cursor.executemany(sql,val)
mycon. () #Line statement2
except:
mycon.rollback() #statement3
Ans. (i) commit
(ii) INTO
(iii) mycon.close()
Explanation: To get and print the ID of the last inserted row, lastrowid is used. This is a special
keyword which is used to get the ID of the last inserted row.