The document contains multiple choice questions, fill-in-the-blanks, true/false questions, and assertion/reasoning questions related to Database Management, SQL querying, and Python interface with MySQL. It covers topics such as database concepts, SQL commands, aggregate functions, joins, and Python database connectivity. The questions assess knowledge of database terminology, SQL syntax, and practical application of database management principles.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
5 views
MULTIPLE CHOICE QUESTIONS-sql
The document contains multiple choice questions, fill-in-the-blanks, true/false questions, and assertion/reasoning questions related to Database Management, SQL querying, and Python interface with MySQL. It covers topics such as database concepts, SQL commands, aggregate functions, joins, and Python database connectivity. The questions assess knowledge of database terminology, SQL syntax, and practical application of database management principles.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6
MULTIPLE CHOICE QUESTIONS
Database Management- Concepts
Q. 1 The term _____is used to refer to a record in a table. (a) Attribute (b) Tuple (c) Field (d) Instance Q. 2 A relational database consists of a collection of (a) Tuple (b) Attribute (c) Relation (d) Keys Q. 3 Which of the following is not a legal sub-language of SQL? (a) DDL (b) QAL (c.) DML (d) TCL Q. 4. What is the full form of DBMS ? (a) Data of Binary Management System (b) Database Management System (c) Database Management Service (d) Data Backup Management System Q. 5. Which type of data can be stored in the database? (a) Image oriented data (b) Text, files containing data (c) Data in the form of audio or video (d) All of the above Q.6 The ability to query data, as well as insert, delete, and alter tuples, is offered by ____________ (a) TCL (Transaction Control Language) (b) DCL (Data Control Language) (c) DDL (Data Definition Langauge) (d) DML (Data Manipulation Langauge) Q.7 Which command is used to remove a relation from an SQL? (a) Drop table (b) Delete (c) Purge (d) Remove Q.8 Which of the following is not the utility of DBMS? (a) Backup (b) Data Loading (c) Process Organization (d) File organization Q.9 Which of the following is a component of the DBMS? (a) Data (b) Data Languages (c) Data Manager (d) All of the above Q.10 Which of the following is the subset of SQL commands used to manipulate Database Structures, including tables ? (a) Data Described Language (b) Data Retrieval Language (c) Data Manipulation Language (d) Data Definition Language Q.11 DML stands for (a) Data Manageable Language (b) Domain Manipulation Language (c) Data Manipulation Language (d) None of the above Q. 12 Which is the following not a DDL command ? (a) CREATE (b) UPDATE (c) ALTER (d) TRUNCATE Q. 13 Which is the following not a DML command ? (a) SELECT (b) UPDATE (c) DELETE (d) CREATE Q. 14 Which is the following considered as DBMS ? (a) Access (b) Oracle (c) SQL Server (d) All of the above Q.15 A row is also called ______ (a) Field (b) Tuple (c) both a and b (d) None of the above FILL IN THE BLANKS Q.16 A pool of values wherefrom a field can draw values is called ____ Q.17 A raw in a relation is called _______ Q.18 The number of attribute in a relation is called its _______ Q.19 Collection of logically related data tables is called ________ Q.20 A non-key attribute derived from the primary key of some other relation is called _______ TRUE / FALSE QUESTIONS Q. 21 The duplication of data is known as data redundancy. Q.22 A table in a relational database can store empty values. Q.23 Common attribute of two tables is called a foreign key. Q.24 The DDL commands are used to define or redefine schema objects. Q.25 A primary key can store empty values in it. ASSERTIONS AND REASONS Directions : In the following questions, a statement of Assertion (A) is followed by a statement of Reason (R). Mark the correct choice as: (a) Both A and R are true and R is the correct explanation of A. (b) Both A and R are true but R is not the correct explanation of A. (c) A is true but R is false (or partly true) (d) A is false (or partly true) but R is true. Q. 26 Assertion (A). A database is centrally stored data and a DBMS is a system to manage the database. Reason(R). DBMS is a database management system, which is a software managing the databases. Q. 27 Assertion (A). Data redundancy may lead to data inconsistency. Reason (R). When redundant data or the multiple copies of data mismatch, it makes the data inconsistent. Q. 28 Assertion (A). Data redundancy may lead to may problems. Reason (R). In RDBMS, data redundancy is 100% removed. Q. 29 Assertion (A). A primary key is used to uniquely identify the rows in a data table. Reason (R). A primary key is a field or attribute which has a unique value for each row or tuple. Q. 30 Assertion (A). A data table can have only one primary key. Reason (R). In a data table, there can be only one attribute/field containing unique values for each row. MYSQL - Querying using SQL Q.1 Which of the following is/are the DDL Statement ? (a) Create (b) Drop (c) Alter (d) All of these Q.2 A Table can have __________ (a) Many primary keys and many unique keys. (b) One primary key and one unique key (c) One primary key and many unique keys. (d) Many primary keys and one unique key. Q.3 Which of the following types of table constraints will prevent the entry of duplicate rows? (a) Unique (b) Distinct (c) Primary Key (d) Null Q.4 Consider the following SQL Statement. What type of statement is this ? INSERT INTO instructor VALUES (10211, ‘SHREYA’ , ‘BIOLOGY’, 69000); (a) Procedure (b) DML (c) DCL (d) DDL Q. 5 Which of the following statements will delete all rows in a table namely mytable without deleting the table’s structure. (a) DELETE FROM mytable;’ (b) DELETE TABLE mytable; (c) DROP TABLE mytable; (d) None of these. Q.6 Which of the following query will drop a column from a table ? (a) DELETE COLUMN column_name; (b) DROP COLUMN column_name; (c) ALTER TABLE table_name DROP COLUMN column_name; (d) None of these Q. 7 Logical operator used in SQL are: (a) AND, OR, NOT (b) &&, ||, ! (c) $,|,! (d) None of these Q. 8 Which of the following requirement can be implemented using a CHECK constraint? (a) Student must be greater than 18 years old. (b) Student must be form a BRICS Country (Brazil, Russia, India, China) (c) Student’s roll number must exist in another table(say, namely Eligible) (d) None of these Q.9 The statement in SQL which allows to change the definition of a table is (a) Alter (b) Update (c) Create (d) select Q.10 The statement in SQL which allows to change the definition of a table is (a) Alter (b) Update (c) Create (d) select Q.11 Key to represent relationship between tables is called (a)Primary key (b) Secondary Key (c) Foreign Key (d) None of these Q.12 _____ produces the relation that has attributes of R1 and R2 (a) Cartesian product (b) Difference (c) Intersection (d) Product Q.13 It is better to use files than a DBMS when there are (a)Stringent real-time requirements. (b) Multiple users wish to access the data. (c) Complex relationships among data (d) All of the above. Q.14 The conceptual model is (a)dependent on hardware. (b)dependent on software. (c)dependent on both hardware and software . (d)independent of both hardware and software. Q.15 What is a relationship called when it is maintained between two entities? (a) Unary (b) Binary (c) Ternary (d) Quaternary Q.16 Which of the following operation is used if we are interested in only certain columns of a table? (a) PROJECTION (b) SELECTION (c) UNION (d) JOIN Q.17 Which of the following is a valid SQL type? (a) CHARACTER (b) NUMERIC (c) FLOAT (d) All of the above Q.18 The RDBMS terminology for a row is (a)tuple (b) relation (c) attribute (d) degree. Q.19 State whether the following statement is True or False : In MYSQL, you can write multiple statements in a single line. Q.20 State whether the following statement is True or False : In MYSQL, you can change the column name using UPDATE command. Q.21 State whether the following statement is True or False : In MYSQL, PRIMARY KEY and UNIQUE KEY both are the same. Q.22 State whether the following statement is True or False : By default, the result of an order by clause is always displayed in ascending order. Q.23 Fill in the blank : ________ operator checks whether the particular condition record exists in the table or not. Q.24 Fill in the blank: SELECT is a type of _________ SQL command. Q.25 Which MySQL function is used to get the current date and time? (a) DATETIME( ) (b) TODAY( ) (c) DATE( ) (d) NOW( ) Q.26 to 30 are Assertion (A) and Reasoning (R) based questions. Mark the correct choice as : (a) Both A and R are true and R is the correct explanation of A. (b) Both A and R are true but R is not correct explanation of A. (c) A is true but R is false (or partly true). (d) A is false (or partly true) but R is true. Q.26 Assertion (A) : There is a difference between a field being empty or storing NULL value in a field. Reason (R) : The NULL value is a legal way of signifying that no value exists in the field. Q. 27 Assertion (A) : DDL and DML both are part of SQL. Reason (R) : Both DDL and DML are interchangeable. Q. 28 Assertion (A) : both WHERE and HAVING clauses are used to specify conditions. Reason (R) : Both WHERE and HAVING are interchangeable. Q.29 Assertion (A) : DDL and DML both are not the same. Reason (R) : DDL and DML are two subcategories of SQL where DDL creates the objects and DML manipulates the data. Q.30 Assertion (A) : both BETWEEN and IN operators can choose from a list of values. Reason (R) : The value ranges and a list of values are interpreted in the some way in SQL. TOPIC- GROUPING RECORD, JOIN IN SQL 1. Which clause is used with "aggregate function? a) Group by b) Select c) where d) both a and c 2. A ____ is a query that retrieves rows from more than one table or view? a) Start b) End c) Join d) All of these 3 Aggregate function can be used in the select list or the ___ clause of a select statement . They cannot be used in a ____ clause? a) Where , having c) Group by, having. b) Having, where d) Group by, where 4. A Cartesian product is returned when ? a) A join condition is omitted. b) A join condition is invalid. c) All the rows in the first table are joined to all the rows in second table. d) All of these. 5. All Aggregate function ignore NULLs except for ____ function? a) Distinct b) count (*) c) Average d) None of these 6. SQL applies condition on the groups through _____ clause after groups have been formed ? a) Group by b) with c) where d) having 7. Which of the following group function ignore NULL values? a) MAX b) COUNT c) SUM d) All of these 8. Which SQL function is used to count the number of rows in a SQL query? a) COUNT ( ) b) Number ( ) c) SUM( ) d) COUNT (*) 9. Function count ( ) is an ____ function ? a) Single row b) Multiple rows c) Aggregate d) None of these 10. Which of the following is not an aggregate function? a) Avg b) Sum c) With d) Min 11. Which of the following is a SQL aggregate function? a) Left b) Avg c) Join d)Len 12. The Sum ( ) if used in condition is used with ____ clause ? a) Group by b) With c) Where d) Having 13. The Where and Having clause can be used interchangeable in SELECT queries? a) True b) False c) only in view d) with order by 14. What is the meaning of HAVING clause in select query? a) To filter out the summary groups. b) To filter out the column groups. c) To filter out the row and column values. d) None of the above. 15.For the HAVING clause which of the following phase is/are ture ? a) Act EXACTLY like a WHERE clause. b) Act like a WHERE clause but is used for columns rather than groups. c) Act like a WHERE clause but is used for groups rather than rows. d) Act like a WHERE clause but is used for rows rather than columns. 16. Consider the following statement and tell if it Ture for all cases or in specific cases. Having clause is processed after the GROUP BY clause and any aggregate functions. a) True for all cases b) False for all cases c) True when there is no WHERE clause. d) True only with where clause 17. The following SQL is which type of join: SELECT CUSTOMER.CUST_ID, ORDER.CUST_ID, NAME, ORDER _ID FROM CUSTOMER, ORDER Where CUSTOMER.CUST_ID = ORDER.CUST_ID; a) Equal-join b) Natural join c) Outer join d) Cartesian product 18.The following SQL is which type of join: Select customer.cust_id, order.cust_id,name, order_id From CUSTOMER, ORDER ; a) Equal-join b) Natural join c) Outer join d) Cartesian Product 19.Which product is returned in a join query having no join condition? a) Equal-join c) Both (a) and (b) b) Cartesian product d) none of the mentioned 20.which is a Join condition that contains an equality operator ? a)Equijoin b) Cartesian Product c) Both a and b d) None of the mentioned. Fill in the blank: 21. To compare an aggregate value in a condition,______ clause is used. 22.To create a summary of records based on the common value in a field in different rows of the table ______ clause is used. 23. In equi join, the join condition joins the two tables using ________ operator 24. The equi join uses ______ operator in the join condition. 25. Aggregate function cannot be used in ______ clause of the select query. True/False Questions: 26. Equi join can use any operator for joining two tables. 27. The HAVING and WHERE clauses are interchangeable. 28. The SQL keyword GROUP BY instructs the DBMS to group together those rows that have same value in a column. 29.The HAVING clause can take any valid SQL function in its conditions. 30.Join can only be created from two tables. TOPIC-INTERFACE PYTHON WITH MYSQL 1. In order to open a connection with MYSQL database from within Python using mysql.connection package,____ function is used ? (a) open ( ) (b) database( ) (c) connect( ) (d) connectdb( ) 2. A database______ controls the connection to an actual datadabe, established from within a python program? (a) database object (b) connection object (c) fetch object (d) object 3 The set of records retrieved after executing an SQL query over an established database connection is called ? (a) table (b) sqlresult (c) result (d) resultset 4.A database _______ is a special control structure that facilities the rows by the row processing of records in the retrieved resultset. ? (a) fetch (b) table (c) cursor (d) query 5.Which of the following is not legal method for fetching records from database from within a python program ? (a) fetchone( ) (b) fetchwo ( ) (c) fetchall (d)fetchmany( ) 6.To fetch one records retrieved you may use <cursor> ______ method. (a) fetch( ) (b) fetchone ( ) (c)fetchtuple() (d)fetchmany() 7. To fetch All records retrieved you may use <cursor> ______ method. (a) fetch( ) (b) fetchone ( ) (c)fetchall() (d)fetchmany() 8. To run an SQL query from python program you may use <cursor> method. (a) query() (b) execute () (c) run() (d) all of these 9. To reflect the changes made in the database permanently, you need to <connection>._______ method. (a) done() (b) reflect() (c) commit() (d) final() 10. Which of the following libraries may be used for connecting with a MySQL database from a Python program? (a) mysql.connector (b) pymysql (c) mMySQLServer (d)MySQLClient 11. After importing the connection library, first thing you do is: establish MySQLdatabase. (a) Cursor (b) setup (c) Resultset (d) connection 12. Identify the name of connector to establish bridge between Python and MySQL (a) mysql.connection (b) connector (c) mysql.connect (d)mysql.connector 13. In the following connection string: Identify the elements: connect(__<<1>>____ = 127.0.0.1, ____<<2>>____ =‟ root‟, _____<<3>>____ = „admin‟) (a) <<1>> = User, <<2>> = password, <<3> = host (b)<<1>> = host, <<2>> = user, <<3> = password (c)<<1>> = host, <<2>> = password, <<3> = user (d) <<1>> = IP, <<2>> = user, <<3> = password 14. Which function of connection is used to check whether connection to mysql is successfully done or not? import mysql.connector as msq con = msq.connect( #Connection String ) # Assuming all parameter required as passed if _______________: print(“Connected!”) else: print(“ Error! Not Connected”) (a) con.connected() (b) con.isconnected() (c) con.is_connected() (d) con.is_connect() 15. Which of the following component act as a container to hold all the data returned from the query and from there we can fetch data one at a time? (a) ResultSet (b) Cursor (c) Container (d) Table 16. Identify the correct statement to create cursor: import mysql.connector as msq con = msq.connect( #Connection String ) # Assuming all parameter required as passed mycursor = _________________ (a) con.cursor() (c) con.open_cursor() (b) con.create_cursor() (d) con.get_cursor() 17. Which attribute of of cursor is used to get number of records stored in cursor (Assuming cursor name is mycursor)? (a) mycursor.count (c) mycursor.records (b) mycursor.row_count (d) mycursor.rowcount 18. Which of the Symbols are used for passing parameterized query for execution to cursor? (a) % (b) { } (c) $ (d) Both a and b 19. Which function is used to fetch n number of records from cursor? (a) fetch() (b) fetchone() (c) fetchmany() (d) fetchall() 20. Which cursor function is used to send query to connection? (a) query() (b) execute() (c) run() (d) send() Fill in the blank: 21. After importing mysql.connector, first of all____ _____ is established using connect(). 22. After establishing database connection, database______ is created so that the sql query may be executed through it to obtain resultset. 23. The _________ returns how many rows have been fetched to far using various fetch methods. 24. The running of sql query through database cursor results into all the records returned in the form of _________. 25. A connectivity package such as________ must be imported before writing database. connectivity Python code. True/False Questions: 26.The SQL query upon execution via established database connection returns the result in multiple chunks. 27.The cursor.rowcount gives the count in the resultset. 28.The cursor.rowcount return how many rows have been so far retrieved through fetch() methods from the cursor.. 29.A DELETE or UPDATE or INSERT query requires commit( ) to reflect the changes in the database. 30. Unique and Primary key constraints are the same.