Font size
WorksheetsDatabase Management Worksheet Questions
Total questions: 115
Worksheet time: 58mins
A data ________ is a restriction or limitation to ensure accuracy and reliability of data in database
Constraint
Dictionary
Query
None of these
A ________ is a type of command that retrieves data from a database on a server
Constraint
Dictionary
Query
None of these
RDBMS stands for
Relational Database Management System
Rotational Database Management System
Reliable Database Management System
None of these
An attribute or set of attributes that is used to uniquely identify a record in a database table is called
A primary key
An identifier
A tuple
None of the above
A primary key consisting of more than one attribute is called
Composite Primary Key
Foreign Key
Alternate Key
None of these
Each row of data in a relation(table) is called
attribute
tuple
domain
None of these
Column headings in a relation are referred as
attributes
tuples
domains
None of these
________ is a set of values from which an attribute can take a value in each row
Attribute
Tuple
Domain
None of these
The number of attributes in a relation is called the ________ of the relation
Degree
Cardinality
Domain
None of these
The number of tuples in a relation is called the ________ of the relation
Degree
Cardinality
Domain
None of these
A ________ is used to represent the relationship between two relations
Composite Key
Foreign Key
Alternate Key
None of these
An attribute or set of attributes that can be served as a primary key of a relation is called
Service Key
Foreign Key
Candidate Key
None of these
A candidate key that is not the primary key is called
Composite Key
Foreign Key
Alternate Key
None of these
In relational model, tables are called
Domains
Relations
Tuples
None of these
________ can take NULL values in it
Primary Key
Foreign Key
Both Primary Key and Foreign Key
None of these
A relational database consists of a collection of
Tables
Fields
Records
Keys
A/An ________ in a table represents a logical relationship among a set of values.
Attribute
Key
Tuple
Entry
The term ________ is used to refer to a record in a table.
Attribute
Tuple
Field
Instance
Which of the following attributes cannot be considered as a choice for primary key?
Id
License Number
Dept_Id
Street
An attribute in a relation is a foreign key if it is the ________ key in any other relation.
Candidate
Primary
Super
Sub
Consider the table with structure as: Student (ID, name, dept_name, tot_cred). In the above table, which attribute will form the primary key?
Name
Dept
Total_credits
ID
Which one of the following is commonly used to define the overall design of the database?
Application program
Data definition language
Schema
Source code
The term "SQL" stands for
Standard query language
Sequential query language
Structured query language
Server-side query language
Which of the following data type will be suitable for storing the name of students?
int
varchar(n)
char
None of the above
What is the format used for storing date using date datatype?
dd-mm-yy
dd-mm-yyyy
mm-dd-yyyy
yyyy-mm-dd
Which of the following constraints can be used if we don’t want user to leave the field blank while inserting data?
"NULL"
not null
"Unassigned"
unique key
Which of the following data type will be the best choice for storing price of any item?
string
int
date
float
A relational database consists of a collection of
Tables
Fields
Records
Keys
Which of the following is NOT a DML command?
SELECT
DELETE
UPDATE
DROP
Identify the correct SQL command that deletes all rows of a table TEMP without deleting its structure.
DELETE TABLE TEMP;
DROP TABLE TEMP;
REMOVE TABLE TEMP;
DELETE FROM TEMP;
Which is not a constraint in SQL?
Unique
Distinct
Primary key
Check
For each attribute of a relation, there is a set of permitted values, called the _____ of that attribute.
Dictionaries
Domain
Directory
Relation
_____ key is used to join two relations in RDBMS?
Primary Key
Candidate Key
Foreign Key
Unique Key
What is the degree and cardinality of a SQL table?
Number of columns and Number of rows
Number of rows and Number of columns
Number of keys and Number of constraints
None
_____ command helps to fetch data from relation.
Use
Show
Fetch
Select
A _____ is a text that is not executed.
Statement
Query
Comment
Clause
_____ command helps to open the database for use.
Use
Open
Distinct
Select
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:
ALTER TABLE emp ADD bonus NUMBER;
CREATE TABLE emp ADD COLUMN bonus;
UPDATE TABLE emp SET bonus;
INSERT INTO emp (bonus) VALUES (100);
What is the full form of SQL?
Structured Query Language
Structured Query List
Simple Query Language
Data Derivation Language
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?
Where
from
having
like
Which subset of SQL commands is used to manipulate database structure including tables?
Data Definition Language (DDL)
Data Manipulation Language (DML)
Both (a) and (b)
None
The term used to refer to a field in a table is what?
Attribute
Tuple
Row
Instance
This SQL query selects: SELECT name FROM Emp WHERE salary IS NOT NULL;
Tuple with null values
Tuples with no null values
Tuples with any salary
All of the above
What does DML & DDL stands for?
Data Manipulation Language (DML) & Data Definition Language (DDL)
Data Mode Lane (DML) & Data Definition Language (DDL)
Different Mode Level (DML) & Data Derivation Language (DDL)
Data Model Language (DML) & Dynamic Data Language (DDL)
Which of the following sublanguages of SQL is used to define the structure of the relation, deleting relations and relating schemas?
Data Definition Language (DDL)
Data Manipulation Language (DML)
Query
Relational Databases
Consider the following SQL statement. What type of statement is this? SELECT * FROM Employee ;
DML
DDL
DCL
Integrity Constraint
The data types CHAR (n) and VARCHAR (n) are used to create ________ and ________ length types of string/text fields in a database.
Fixed, Equal
Equal, Variable
Fixed, Variable
Variable, Equal
Which of the following is/are the DDL statements?
Create
Drop
Alter
All of these
defines rules regarding the values allowed in columns and is the standard mechanism for enforcing database integrity.
Column
Constraint
Index
Trigger
To define a column as a primary key, __________ __________ constraint is used in CREATE TABLE.
primary word
primary keynote
candidate key
primary key
Which command we use to create a database in MySQL.
CREATE DATABASE database_name;
CREATE SCHEMA database_name;
USE database_name;
SELECT DATABASE;
Sonia wants to see all the databases available in her MySQL software. Which command is useful for her?
Show databases;
Show database;
Show tables;
Show database_name;
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.
Required database;
Use database;
Use
Required
To delete a database ________ command is used.
Delete database database_name
Delete database_name
Drop database database_name
Drop database_name
To show all the tables of a given database what will be the command?
Use database_name; shows tables;
Use database_name; show tables;
Required database; show tables;
Required database; shows tables;
Consider the SQL statement: CREATE TABLE employee (name VARCHAR, id INTEGER). What type of statement is this?
DML
DDL
DCL
Integrity constraint
Which among the following is the correct syntax for creating tables?
CREATE TABLE name;
CREATE name;
CREATE TABLE
All of the mentioned
Which command shows the table structure of table emp?
Select * from emp;
Show all from emp;
Desc emp;
Drop emp;
Which of the following functions are not performed by the "ALTER" clause?
Change the name of the table
Change the name of the column
Drop a column
All of the mentioned
The ______ clause of SELECT query allows us to select only those rows in the results that satisfy a specified condition.
Where
from
having
like
Which command is used to change the definition of a table in SQL?
create
update
alter
delete
In the given query which keyword has to be inserted? INSERT INTO employee ______ (1002, "Kausar", 2000);
Table
Values
Relation
Field
Which operator is used to compare a value to a specified list of values?
Between
All
In
None of the above
You can change or modify the value for one or more columns of a table using SQL with which of the following?
Change
Modify
Alter
Update
Which operator checks a column for nonexistence of data in that column?
NOT Operator
Exists Operator
IS NULL Operator
None of the above
If we have not specified ASC or DESC after a SQL ORDER BY clause, which is used by default?
DESC
ASC
There is no default value
None of the mentioned
Which of the following is true about the SQL AS clause?
The AS clause in SQL is used to change the column name in the output or assign a name to a derived column.
The SQL AS clause can only be used with the JOIN clause.
The AS clause in SQL is used to define a search condition.
All of the mentioned
The SQL keyword(s) used with wildcards is which of the following?
LIKE only
IN only
NOT IN only
IN and NOT IN
The numerical values of two ____ of the ____ table can be easily subtracted using the SQL subtraction operator.
Rows, same
Columns, same
Rows, different
Columns, different
Which of the following function is used to find the largest value from the given data in MySQL?
MAX()
MAXIMUM()
LARGEST()
BIG()
Aggregate functions can be used in the select list or the ______ clause of a select statement. They cannot be used in a ______ clause.
Where, having
Having, where
Group by, having
Group by, where
Which of the following is a SQL aggregate function?
LEFT()
AVG
JOIN
LEN
An attribute in a relation is a foreign key if it is the ______ key in any other relation.
Candidate
Primary
Super
Sub
The HAVING clause does which of the following?
Acts EXACTLY like WHERE clause
Acts like a WHERE clause but is used for columns rather than groups
Acts like a WHERE clause but is used for groups rather than rows
Acts like a WHERE clause but is used for rows rather than columns
Which SQL function is used to count the number of rows in a SQL query?
COUNT()
NUMBER()
SUM()
COUNT(*)
With SQL, how can you return the number of not null records in the Project field of the Students table?
SELECT COUNT(Project) FROM Students
SELECT COLUMNS(Project) FROM Students
SELECT COLUMNS(*) FROM Students
SELECT COUNT(*) FROM Students
Which of the following is not an aggregate function?
Avg
Sum
Sub
Min
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?
75000
25000
10000
50000
Which of the following group functions ignore NULL values?
MAX
COUNT
SUM
All of the above
Where and Having clauses can be used interchangeably in SELECT queries.
True
False
Only in views
With order by
The operation whose result contains all pairs of tuples from the two relations, regardless of whether their attribute values match.
Join
Cartesian product
Intersection
Set difference
To specify filtering condition for groups, the ______ clause is used in MySQL.
where
having
order by
both a and b
______ clause is used to collect those rows that have the same value in a specified column.
order by
like
having
group by
The SQL built-in function ______ computes the number of rows in a table.
count(*)
count(Column name)
sum(column)
both a and b
We apply the aggregate function to a group of sets of tuples using the ______ clause.
group by
group
group set
group attribute
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;
The having clause checks whether the query result is true or not
The having clause does not check for any condition
The having clause allows only those tuples that have average balance 10000
None of the mentioned
The aggregation operation that adds up all the values of the attribute is
add
avg
max
sum
What values does the count(*) function ignore?
Repetitive values
Null values
Characters
Integers
Which join is equivalent to a Cartesian product?
INNER JOIN
OUTER JOIN
CROSS JOIN
NATURAL JOIN
How many tables may be included with a join?
One
Two
Three
All of the Mentioned
What is the meaning of the HAVING clause in a SELECT query?
To filter out the summary groups
To filter out the column groups
To filter out the row and column values
None of the above
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
Equi-join
Natural join
Outer join
Cartesian join
Select the correct query/queries for cross join:
Select * FROM Table1 T1 NATURAL JOIN Table1 T2;
Select * FROM Table1 T1 ALL CROSS JOIN Table1 T2;
Select * FROM Table1 T1, Table1 T2;
Select * FROM Table1 T1 CROSS Table1 T2;
SQL applies conditions on the groups through the clause used after groups have been formed.
Group by
With
Where
Having
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?
Equi-join
Natural join
Outer join
Cartesian join
Which MySQL driver you need to install for connection of Python with MySQL
mysql-connector
mysql.connector
mysql-connect
All of the above
The ………… creates a connection to the MySQL server and returns a Connection object.
connect()
connection()
connector()
None of the above
It acts as middleware between MySQL database connection and SQL query.
cursor
Table
Query
row
Suresh is trying to fetch only one record from result set at a time. Which method should be used by him?
fetchmany
fetchno
fetchone
fetchall
SQL command is passed to which function to run after establishment of the connection between Python and database
cursor()
execute()
connection()
fetchall()
Which of the following function is used to close the connection between Python and database?
cursor.close()
is.close()
connection.close()
execute.close()
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?
Cursor.query.excute()
Cursor.execute(Query)
Query.execute()
execute(Query)
When we run
done()
commit()
reflect()
final()
Which function retrieve all (remaining) rows of a query result and return them in a list of tuples
fetchone()
fetchall()
fetchmany()
All the above
Which is the correct statement about fetchone()
Fetch the next row of a query result set, returning a single tuple, or None when no more data is available
Fetch the First row of a query result set, returning a single tuple, or None when no more data is available
Fetch the current row of a query result set, returning a single tuple, or None when no more data is available
None of the above
What is the datatype of the row returned from a resultset using fetchone() function?
Tuple
List
String
Dictionary
What is the datatype of the row returned from a resultset using fetchall() function?
Tuple
List
String
Dictionary
What is the datatype of the row returned from a resultset using fetchmany() function?
Tuple
List
String
Dictionary
What is returned when we execute the function fetchone() but no rows are available to fetch?
None
Empty Tuple
Empty List
Error
What is returned when we execute the function fetchall() but no rows are available to fetch?
None
Empty Tuple
Empty List
Error
What is returned when we execute the function fetchmany() but no rows are available to fetch?
None
Empty Tuple
Empty List
Error
Which function is called to make mysql connection with python?
execute
commit
connect
fetchone
This is the Property of cursor object that returns the number of rows fetched.
fetchall()
resultset
rowcount
none of the above
Whenever you run Insert, Update and Delete query using Python code, you must run method within the connection object.
fetchall()
commit()
executeQ
None of the above
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)
5
3
-1
None
