wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Database Management Worksheet Questions

Total questions: 115

Worksheet time: 58mins

Name
Class
Date
1.

A data ________ is a restriction or limitation to ensure accuracy and reliability of data in database

a)

Constraint

b)

Dictionary

c)

Query

d)

None of these

2.

A ________ is a type of command that retrieves data from a database on a server

a)

Constraint

b)

Dictionary

c)

Query

d)

None of these

3.

RDBMS stands for

a)

Relational Database Management System

b)

Rotational Database Management System

c)

Reliable Database Management System

d)

None of these

4.

An attribute or set of attributes that is used to uniquely identify a record in a database table is called

a)

A primary key

b)

An identifier

c)

A tuple

d)

None of the above

5.

A primary key consisting of more than one attribute is called

a)

Composite Primary Key

b)

Foreign Key

c)

Alternate Key

d)

None of these

6.

Each row of data in a relation(table) is called

a)

attribute

b)

tuple

c)

domain

d)

None of these

7.

Column headings in a relation are referred as

a)

attributes

b)

tuples

c)

domains

d)

None of these

8.

________ is a set of values from which an attribute can take a value in each row

a)

Attribute

b)

Tuple

c)

Domain

d)

None of these

9.

The number of attributes in a relation is called the ________ of the relation

a)

Degree

b)

Cardinality

c)

Domain

d)

None of these

10.

The number of tuples in a relation is called the ________ of the relation

a)

Degree

b)

Cardinality

c)

Domain

d)

None of these

11.

A ________ is used to represent the relationship between two relations

a)

Composite Key

b)

Foreign Key

c)

Alternate Key

d)

None of these

12.

An attribute or set of attributes that can be served as a primary key of a relation is called

a)

Service Key

b)

Foreign Key

c)

Candidate Key

d)

None of these

13.

A candidate key that is not the primary key is called

a)

Composite Key

b)

Foreign Key

c)

Alternate Key

d)

None of these

14.

In relational model, tables are called

a)

Domains

b)

Relations

c)

Tuples

d)

None of these

15.

________ can take NULL values in it

a)

Primary Key

b)

Foreign Key

c)

Both Primary Key and Foreign Key

d)

None of these

16.

A relational database consists of a collection of

a)

Tables

b)

Fields

c)

Records

d)

Keys

17.

A/An ________ in a table represents a logical relationship among a set of values.

a)

Attribute

b)

Key

c)

Tuple

d)

Entry

18.

The term ________ is used to refer to a record in a table.

a)

Attribute

b)

Tuple

c)

Field

d)

Instance

19.

Which of the following attributes cannot be considered as a choice for primary key?

a)

Id

b)

License Number

c)

Dept_Id

d)

Street

20.

An attribute in a relation is a foreign key if it is the ________ key in any other relation.

a)

Candidate

b)

Primary

c)

Super

d)

Sub

21.

Consider the table with structure as: Student (ID, name, dept_name, tot_cred). In the above table, which attribute will form the primary key?

a)

Name

b)

Dept

c)

Total_credits

d)

ID

22.

Which one of the following is commonly used to define the overall design of the database?

a)

Application program

b)

Data definition language

c)

Schema

d)

Source code

23.

The term "SQL" stands for

a)

Standard query language

b)

Sequential query language

c)

Structured query language

d)

Server-side query language

24.

Which of the following data type will be suitable for storing the name of students?

a)

int

b)

varchar(n)

c)

char

d)

None of the above

25.

What is the format used for storing date using date datatype?

a)

dd-mm-yy

b)

dd-mm-yyyy

c)

mm-dd-yyyy

d)

yyyy-mm-dd

26.

Which of the following constraints can be used if we don’t want user to leave the field blank while inserting data?

a)

"NULL"

b)

not null

c)

"Unassigned"

d)

unique key

27.

Which of the following data type will be the best choice for storing price of any item?

a)

string

b)

int

c)

date

d)

float

28.

A relational database consists of a collection of

a)

Tables

b)

Fields

c)

Records

d)

Keys

29.

Which of the following is NOT a DML command?

a)

SELECT

b)

DELETE

c)

UPDATE

d)

DROP

30.

Identify the correct SQL command that deletes all rows of a table TEMP without deleting its structure.

a)

DELETE TABLE TEMP;

b)

DROP TABLE TEMP;

c)

REMOVE TABLE TEMP;

d)

DELETE FROM TEMP;

31.

Which is not a constraint in SQL?

a)

Unique

b)

Distinct

c)

Primary key

d)

Check

32.

For each attribute of a relation, there is a set of permitted values, called the _____ of that attribute.

a)

Dictionaries

b)

Domain

c)

Directory

d)

Relation

33.

_____ key is used to join two relations in RDBMS?

a)

Primary Key

b)

Candidate Key

c)

Foreign Key

d)

Unique Key

34.

What is the degree and cardinality of a SQL table?

a)

Number of columns and Number of rows

b)

Number of rows and Number of columns

c)

Number of keys and Number of constraints

d)

None

35.

_____ command helps to fetch data from relation.

a)

Use

b)

Show

c)

Fetch

d)

Select

36.

A _____ is a text that is not executed.

a)

Statement

b)

Query

c)

Comment

d)

Clause

37.

_____ command helps to open the database for use.

a)

Use

b)

Open

c)

Distinct

d)

Select

38.

If you want to add a new column in an existing table, which command is used? For example, to add a column bonus in a table emp, the statement will be given as:

a)

ALTER TABLE emp ADD bonus NUMBER;

b)

CREATE TABLE emp ADD COLUMN bonus;

c)

UPDATE TABLE emp SET bonus;

d)

INSERT INTO emp (bonus) VALUES (100);

39.

What is the full form of SQL?

a)

Structured Query Language

b)

Structured Query List

c)

Simple Query Language

d)

Data Derivation Language

40.

The clause of a SELECT query that allows us to select only those rows in the results that satisfy a specified condition is which one?

a)

Where

b)

from

c)

having

d)

like

41.

Which subset of SQL commands is used to manipulate database structure including tables?

a)

Data Definition Language (DDL)

b)

Data Manipulation Language (DML)

c)

Both (a) and (b)

d)

None

42.

The term used to refer to a field in a table is what?

a)

Attribute

b)

Tuple

c)

Row

d)

Instance

43.

This SQL query selects: SELECT name FROM Emp WHERE salary IS NOT NULL;

a)

Tuple with null values

b)

Tuples with no null values

c)

Tuples with any salary

d)

All of the above

44.

What does DML & DDL stands for?

a)

Data Manipulation Language (DML) & Data Definition Language (DDL)

b)

Data Mode Lane (DML) & Data Definition Language (DDL)

c)

Different Mode Level (DML) & Data Derivation Language (DDL)

d)

Data Model Language (DML) & Dynamic Data Language (DDL)

45.

Which of the following sublanguages of SQL is used to define the structure of the relation, deleting relations and relating schemas?

a)

Data Definition Language (DDL)

b)

Data Manipulation Language (DML)

c)

Query

d)

Relational Databases

46.

Consider the following SQL statement. What type of statement is this? SELECT * FROM Employee ;

a)

DML

b)

DDL

c)

DCL

d)

Integrity Constraint

47.

The data types CHAR (n) and VARCHAR (n) are used to create ________ and ________ length types of string/text fields in a database.

a)

Fixed, Equal

b)

Equal, Variable

c)

Fixed, Variable

d)

Variable, Equal

48.

Which of the following is/are the DDL statements?

a)

Create

b)

Drop

c)

Alter

d)

All of these

49.

defines rules regarding the values allowed in columns and is the standard mechanism for enforcing database integrity.

a)

Column

b)

Constraint

c)

Index

d)

Trigger

50.

To define a column as a primary key, __________ __________ constraint is used in CREATE TABLE.

a)

primary word

b)

primary keynote

c)

candidate key

d)

primary key

51.

Which command we use to create a database in MySQL.

a)

CREATE DATABASE database_name;

b)

CREATE SCHEMA database_name;

c)

USE database_name;

d)

SELECT DATABASE;

52.

Sonia wants to see all the databases available in her MySQL software. Which command is useful for her?

a)

Show databases;

b)

Show database;

c)

Show tables;

d)

Show database_name;

53.

Goni wants to do some work with her database. She is confused about how to write commands to use the required database. Choose the correct option.

a)

Required database;

b)

Use database;

c)

Use ;

d)

Required

54.

To delete a database ________ command is used.

a)

Delete database database_name

b)

Delete database_name

c)

Drop database database_name

d)

Drop database_name

55.

To show all the tables of a given database what will be the command?

a)

Use database_name; shows tables;

b)

Use database_name; show tables;

c)

Required database; show tables;

d)

Required database; shows tables;

56.

Consider the SQL statement: CREATE TABLE employee (name VARCHAR, id INTEGER). What type of statement is this?

a)

DML

b)

DDL

c)

DCL

d)

Integrity constraint

57.

Which among the following is the correct syntax for creating tables?

a)

CREATE TABLE name;

b)

CREATE name;

c)

CREATE TABLE

d)

All of the mentioned

58.

Which command shows the table structure of table emp?

a)

Select * from emp;

b)

Show all from emp;

c)

Desc emp;

d)

Drop emp;

59.

Which of the following functions are not performed by the "ALTER" clause?

a)

Change the name of the table

b)

Change the name of the column

c)

Drop a column

d)

All of the mentioned

60.

The ______ clause of SELECT query allows us to select only those rows in the results that satisfy a specified condition.

a)

Where

b)

from

c)

having

d)

like

61.

Which command is used to change the definition of a table in SQL?

a)

create

b)

update

c)

alter

d)

delete

62.

In the given query which keyword has to be inserted? INSERT INTO employee ______ (1002, "Kausar", 2000);

a)

Table

b)

Values

c)

Relation

d)

Field

63.

Which operator is used to compare a value to a specified list of values?

a)

Between

b)

All

c)

In

d)

None of the above

64.

You can change or modify the value for one or more columns of a table using SQL with which of the following?

a)

Change

b)

Modify

c)

Alter

d)

Update

65.

Which operator checks a column for nonexistence of data in that column?

a)

NOT Operator

b)

Exists Operator

c)

IS NULL Operator

d)

None of the above

66.

If we have not specified ASC or DESC after a SQL ORDER BY clause, which is used by default?

a)

DESC

b)

ASC

c)

There is no default value

d)

None of the mentioned

67.

Which of the following is true about the SQL AS clause?

a)

The AS clause in SQL is used to change the column name in the output or assign a name to a derived column.

b)

The SQL AS clause can only be used with the JOIN clause.

c)

The AS clause in SQL is used to define a search condition.

d)

All of the mentioned

68.

The SQL keyword(s) used with wildcards is which of the following?

a)

LIKE only

b)

IN only

c)

NOT IN only

d)

IN and NOT IN

69.

The numerical values of two ____ of the ____ table can be easily subtracted using the SQL subtraction operator.

a)

Rows, same

b)

Columns, same

c)

Rows, different

d)

Columns, different

70.

Which of the following function is used to find the largest value from the given data in MySQL?

a)

MAX()

b)

MAXIMUM()

c)

LARGEST()

d)

BIG()

71.

Aggregate functions can be used in the select list or the ______ clause of a select statement. They cannot be used in a ______ clause.

a)

Where, having

b)

Having, where

c)

Group by, having

d)

Group by, where

72.

Which of the following is a SQL aggregate function?

a)

LEFT()

b)

AVG

c)

JOIN

d)

LEN

73.

An attribute in a relation is a foreign key if it is the ______ key in any other relation.

a)

Candidate

b)

Primary

c)

Super

d)

Sub

74.

The HAVING clause does which of the following?

a)

Acts EXACTLY like WHERE clause

b)

Acts like a WHERE clause but is used for columns rather than groups

c)

Acts like a WHERE clause but is used for groups rather than rows

d)

Acts like a WHERE clause but is used for rows rather than columns

75.

Which SQL function is used to count the number of rows in a SQL query?

a)

COUNT()

b)

NUMBER()

c)

SUM()

d)

COUNT(*)

76.

With SQL, how can you return the number of not null records in the Project field of the Students table?

a)

SELECT COUNT(Project) FROM Students

b)

SELECT COLUMNS(Project) FROM Students

c)

SELECT COLUMNS(*) FROM Students

d)

SELECT COUNT(*) FROM Students

77.

Which of the following is not an aggregate function?

a)

Avg

b)

Sum

c)

Sub

d)

Min

78.

If column Salary contains the data set {1000, 15000, 25000, 10000, 15000}, what will be the output after the execution of the query SELECT SUM(DISTINCT SALARY) FROM EMPLOYEE?

a)

75000

b)

25000

c)

10000

d)

50000

79.

Which of the following group functions ignore NULL values?

a)

MAX

b)

COUNT

c)

SUM

d)

All of the above

80.

Where and Having clauses can be used interchangeably in SELECT queries.

a)

True

b)

False

c)

Only in views

d)

With order by

81.

The operation whose result contains all pairs of tuples from the two relations, regardless of whether their attribute values match.

a)

Join

b)

Cartesian product

c)

Intersection

d)

Set difference

82.

To specify filtering condition for groups, the ______ clause is used in MySQL.

a)

where

b)

having

c)

order by

d)

both a and b

83.

______ clause is used to collect those rows that have the same value in a specified column.

a)

order by

b)

like

c)

having

d)

group by

84.

The SQL built-in function ______ computes the number of rows in a table.

a)

count(*)

b)

count(Column name)

c)

sum(column)

d)

both a and b

85.

We apply the aggregate function to a group of sets of tuples using the ______ clause.

a)

group by

b)

group

c)

group set

d)

group attribute

86.

Choose the correct option regarding the query: SELECT branch_name, COUNT(DISTINCT customer_name) FROM depositor, account WHERE depositor.account_number = account.account_number GROUP BY branch_id HAVING avg(balance) = 10000;

a)

The having clause checks whether the query result is true or not

b)

The having clause does not check for any condition

c)

The having clause allows only those tuples that have average balance 10000

d)

None of the mentioned

87.

The aggregation operation that adds up all the values of the attribute is

a)

add

b)

avg

c)

max

d)

sum

88.

What values does the count(*) function ignore?

a)

Repetitive values

b)

Null values

c)

Characters

d)

Integers

89.

Which join is equivalent to a Cartesian product?

a)

INNER JOIN

b)

OUTER JOIN

c)

CROSS JOIN

d)

NATURAL JOIN

90.

How many tables may be included with a join?

a)

One

b)

Two

c)

Three

d)

All of the Mentioned

91.

What is the meaning of the HAVING clause in a 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

92.

The following SQL is which type of join? SELECT CUSTOMER_T. CUSTOMER_ID, ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T, ORDER_T WHERE CUSTOMER_T. CUSTOMER_ID = ORDER_T. CUSTOMER_ID

a)

Equi-join

b)

Natural join

c)

Outer join

d)

Cartesian join

93.

Select the correct query/queries for cross join:

a)

Select * FROM Table1 T1 NATURAL JOIN Table1 T2;

b)

Select * FROM Table1 T1 ALL CROSS JOIN Table1 T2;

c)

Select * FROM Table1 T1, Table1 T2;

d)

Select * FROM Table1 T1 CROSS Table1 T2;

94.

SQL applies conditions on the groups through the clause used after groups have been formed.

a)

Group by

b)

With

c)

Where

d)

Having

95.

The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID, ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T, ORDER_T WHERE CUSTOMER_T. CUSTOMER_ID = ORDER_T. CUSTOMER_ID?

a)

Equi-join

b)

Natural join

c)

Outer join

d)

Cartesian join

96.

Which MySQL driver you need to install for connection of Python with MySQL

a)

mysql-connector

b)

mysql.connector

c)

mysql-connect

d)

All of the above

97.

The ………… creates a connection to the MySQL server and returns a Connection object.

a)

connect()

b)

connection()

c)

connector()

d)

None of the above

98.

It acts as middleware between MySQL database connection and SQL query.

a)

cursor

b)

Table

c)

Query

d)

row

99.

Suresh is trying to fetch only one record from result set at a time. Which method should be used by him?

a)

fetchmany

b)

fetchno

c)

fetchone

d)

fetchall

100.

SQL command is passed to which function to run after establishment of the connection between Python and database

a)

cursor()

b)

execute()

c)

connection()

d)

fetchall()

101.

Which of the following function is used to close the connection between Python and database?

a)

cursor.close()

b)

is.close()

c)

connection.close()

d)

execute.close()

102.

Read the following code and assume that all necessary files are already imported. Mycon = sql.connect(host="localhost", user="root", password="india", database="company") Cursor = mycon.cursor() Query = "Select * from empl" Which will be the next statement to execute query?

a)

Cursor.query.excute()

b)

Cursor.execute(Query)

c)

Query.execute()

d)

execute(Query)

103.

When we run _.________ method, it reflect the changes made in the database permanently.

a)

done()

b)

commit()

c)

reflect()

d)

final()

104.

Which function retrieve all (remaining) rows of a query result and return them in a list of tuples

a)

fetchone()

b)

fetchall()

c)

fetchmany()

d)

All the above

105.

Which is the correct statement about fetchone()

a)

Fetch the next row of a query result set, returning a single tuple, or None when no more data is available

b)

Fetch the First row of a query result set, returning a single tuple, or None when no more data is available

c)

Fetch the current row of a query result set, returning a single tuple, or None when no more data is available

d)

None of the above

106.

What is the datatype of the row returned from a resultset using fetchone() function?

a)

Tuple

b)

List

c)

String

d)

Dictionary

107.

What is the datatype of the row returned from a resultset using fetchall() function?

a)

Tuple

b)

List

c)

String

d)

Dictionary

108.

What is the datatype of the row returned from a resultset using fetchmany() function?

a)

Tuple

b)

List

c)

String

d)

Dictionary

109.

What is returned when we execute the function fetchone() but no rows are available to fetch?

a)

None

b)

Empty Tuple

c)

Empty List

d)

Error

110.

What is returned when we execute the function fetchall() but no rows are available to fetch?

a)

None

b)

Empty Tuple

c)

Empty List

d)

Error

111.

What is returned when we execute the function fetchmany() but no rows are available to fetch?

a)

None

b)

Empty Tuple

c)

Empty List

d)

Error

112.

Which function is called to make mysql connection with python?

a)

execute

b)

commit

c)

connect

d)

fetchone

113.

This is the Property of cursor object that returns the number of rows fetched.

a)

fetchall()

b)

resultset

c)

rowcount

d)

none of the above

114.

Whenever you run Insert, Update and Delete query using Python code, you must run method within the connection object.

a)

fetchall()

b)

commit()

c)

executeQ

d)

None of the above

115.

If mycursor is a valid cursor what will be the output of the following mycursor.execute("select * from student") #student table has 5 rows myresult = mycursor.fetchmany(3) print(mycursor.rowcount)

a)

5

b)

3

c)

-1

d)

None