0% found this document useful (0 votes)
56 views89 pages

Database Management System MCQ

The document contains multiple choice questions (MCQs) related to Database Management Systems (DBMS), covering topics such as definitions, types of databases, functions of DBMS, and SQL commands. It includes explanations for some answers, providing insights into the concepts of data storage, integrity constraints, and relational databases. The questions also address various features and utilities of DBMS, as well as the roles of different components within a database system.

Uploaded by

l.n.sharma666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views89 pages

Database Management System MCQ

The document contains multiple choice questions (MCQs) related to Database Management Systems (DBMS), covering topics such as definitions, types of databases, functions of DBMS, and SQL commands. It includes explanations for some answers, providing insights into the concepts of data storage, integrity constraints, and relational databases. The questions also address various features and utilities of DBMS, as well as the roles of different components within a database system.

Uploaded by

l.n.sharma666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 89

Database Management System MCQ (Multiple Choice

Questions)
2. What is a database?

c) Organized collection of data or information that can be accessed,


updated, and managed

3. What is DBMS?
d) DBMS stores, modifies and retrieves data

4. Who created the first DBMS?


a) Edgar Frank Codd
b) Charles Bachman
c) Charles Babbage
d) Sharon B. Codd

Explanation: Charles Bachman along with his team invented the first DBMS
known as Integrated Data Store (IDS).

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

6. In which of the following formats data is stored in the database


management system?
c) Table

Explanation: The data is stored in a table format intended to manage


the storage of data and manipulate stored data to generate
information.

7. Which of the following is not a type of database?


a) Hierarchical
b) Network
c) Distributed
d) Decentralized

Explanation: Different types are:


1) Centralized
2) Distributed
3) Relational
4) NoSQL
5) Cloud
6) Object-oriented
7) Hierarchical
8) Network- Network model has data stored in a hierarchical network flow.
8. Which of the following is not an example of DBMS?
a) MySQL
b) Microsoft Acess
c) IBM DB2
d) Google

Explanation: MySQL, Microsoft Access, IBM DB2 are database


management systems MySQL is a Linux-based database management
system, Microsoft Access is a tool that is a part of Microsoft Office
used to store data, IBM DB2 is a database management system
developed by IBM.
9. Which of the following is not a feature of DBMS?
a) Minimum Duplication and Redundancy of Data
b) High Level of Security
c) Single-user Access only
d) Support ACID Property

Explanation:
The important features of a database management system are:

 Minimum Duplication and Redundancy of Data


 High Level of Security
 Mulitple-user Access
 Support ACID Property

 User interface provided


10. Which of the following is a feature of the database?
a) No-backup for the data stored
b) User interface provided
c) Lack of Authentication
d) Store data in multiple locations

Explanation: The important features are:


1) Provides backup for the data stored by the user and the user can
retrieve the data whenever required.
2) Provides User-interface to access the data.
3) Only authorized users can access the stored data.
4) Data is stored in one central location but multiple authorized users
can access the data.
11. Which of the following is not a function of the database?
a) Managing stored data
b) Manipulating data
c) Security for stored data
d) Analysing code

12. Which of the following is a function of the DBMS?


a) Storing data
b) Providing multi-users access control
c) Data Integrity
d) All of the above

13. Which of the following is a component of the DBMS?


a) Data
b) Data Languages
c) Data Manager
d) All of the above

Explanation: The components of DBMS are as follows:

1) Hardware: Like a hard drive, monitor, etc.

2) Software: Provides a user interface

3) Data Manager: Manages operations of DBMS.


4) Data: The collection of information on the DB is known as data.

5) Data Languages: Languages like DDL, DML, DAL, and DCL allow to
perform operations like creating, modifying, storing, or retrieving data.
14. Which of the following is known as a set of entities of the same type
that share same properties, or attributes?
a) Relation set -
b) Tuples -
c) Entity set -
d) Entity Relation model –

15. What is information about data called?


c) Meta data

16. What does an RDBMS consist of?


a) Collection of Records
b) Collection of Keys
c) Collection of Tables
d) Collection of Fields

17. The values appearing in given attributes of any tuple in the referencing
relation must likewise occur in specified attributes of at least one tuple in
the referenced relation, according to _____________________ integrity
constraint.
a) Referential

18. _____________ is a hardware component that is most important for the


operation of a database management system.

b) High speed, large capacity disk to store data

19. The DBMS acts as an interface between ________________ and


________________ of an enterprise-class system.
a) Data and the DBMS
b) Application and SQL
c) Database application and the database
d) The user and the software
20. 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) –

21. ______________ is a set of one or more attributes taken collectively to


uniquely identify a record.
a) Primary Key
b) Foreign key - . A candidate key is used to identify tuples in a relation.
c) Super key- Super key is the superset of all the keys in a relation
d) Candidate key - . A candidate key is used to identify tuples in a relation.
22. Which command is used to remove a relation from an SQL?

a) Drop table - The drop table deletes the whole structure of the relation.
b) Delete - : Delete command is used to delete the existing record from the
table.
c) Purge - Purge removes the table which cannot be obtained again.
d) Remove
23. Which of the following set should be associated with weak entity set for
weak entity to be meaningful?
a) Neighbour set
b) Strong entity set
c) Owner set
d) Identifying set

24. Which of the following command is correct to delete the values in the
relation teaches?
a) Delete from teaches;
b) Delete from teaches where Id =’Null’;
c) Remove table teaches;
d) Drop table teaches;

25. Procedural language among the following is __________


a) Domain relational calculus - Non-Procedural Languages
b) Tuple relational calculus - Non-Procedural Languages
c) Relational algebra - Procedural Languages
d) Query language

Explanation: Non-Procedural Languages are Domain relational calculus


and Tuple relational calculus. Relational algebra is a procedural language
that takes input in the form of relation and output generated is also a
relation.
26. _________________ operations do not preserve non-matched tuples.

a) Left outer join - (Left outer join returns all the rows from the table that is
on the left side and matching rows on the right side of the join)
b) Inner join – (Inner join returns all rows when there is at least one match
in BOTH tables)
c) Natural join – (Natural join returns the common columns from the tables
being joined)
d) Right outer join-( A right outer join returns all the rows from the table that
is on the right side and matching rows on the left side of the join.)

27. Which forms have a relation that contains information about a single
entity?
a) 4NF
b) 2NF
c) 5NF
d) 3NF

28. The top level of the hierarchy consists of ______ each of which can
contain _____.

d) Catalogs, Schemas

Explanation: Schemas represent the logical configuration of the


DBMS. Catalogs consist of metadata of the objects and system
settings used.

29. _______ indicates the maximum number of entities that can be


involved in a relationship.
a) Greater Entity Count
b) Minimum cardinality
c) Maximum cardinality
d) ERD

30. The user IDs can be added or removed using which of the following
fixed roles?
a) db_sysadmin
b) db_accessadmin
c) db_securityadmin
d) db_setupadmin

32. The traditional storage of data organized by the customer, stored in


separate folders in filing cabinets is an example of ______________ type
of ‘database’ management system.

a) Object-oriented database management system – (the data is stored in


the form of objects)
b) Relational database management system – (the data is stored in the
form of tables)
c) Network database management system- Network model has data stored
in a hierarchical network flow.
d) Hierarchical database management system- (Hierarchy is obtained by
Parent-Child Relationship. Parent-Child Relationship Type is basically a
1:N relationship.)

33. After groups have been established, SQL applies predicates in the
___________ clause, allowing aggregate functions to be used.
a) Where
b) Having - HAVING clause is used to filter the groups based on specific
conditions. It allows the use of aggregate functions and selects only the
groups that ,, satisfy the given criteria.
c) Group by - In SQL, after grouping data using the GROUP BY clause
d) With
34. Which of the following is not the utility of DBMS?
i) Backup ii) Loading iii) Process Organization iv) File organization
a) i, ii, and iv only/
Explanation: Back up utility is used to create a copy of the db as a
backup. Loading utility is used to load existing file. File organization is
used to relocate the files and create new access path. Processing is not an
utility.
35. What does a foreign key combined with a primary key create?
a) Network model between the tables that connect them

36. Which of the following is correct according to the technology deployed


by DBMS?
a) Pointers are used to maintain transactional integrity and consistency
b) Cursors are used to maintain transactional integrity and consistency
c) Locks are used to maintain transactional integrity and consistency
d) Triggers are used to maintain transactional integrity and consistenc.

37. Which of the following is correct regarding the file produced by a


spreadsheet?
a) can be used as it is by the DBMS

38. What is the function of the following command?

Delete from r where P;

a) Clears entries from relation


b) Deletes relation
c) Deletes particular tuple from relation
d) All of the mentioned

39. ______ resembles Create view.


a) Create table . . . as
b) Create view as
c) Create table . . .like
d) With data

41. When the “ROLLUP” operator for expression or columns within a


“GROUP BY” clause is used?
c) Group expressions or columns specified in a GROUP BY clause in
one direction, from right to left, for computing the subtotals
42. Which of the following is the best way to represent the attributes in a
large db?
a) Dot representation
b) Concatenation
c) Relational-and
d) All of the mentioned

43. Which of the following is the subset of SQL commands used to


manipulate Oracle Structures, including tables?
a) Data Described Language
b) Data Retrieval Language
c) Data Manipulation Language
d) Data Definition Language

44. Which of the following functions construct histograms and use buckets
for ranking?
a) Ntil()
b) Newtil()
c) Rank()
d) All of the mentioned

45. __________ command is used in SQL to issue multiple CREATE


TABLE, CREATE VIEW and GRANT statements in a single transaction.
a) CREATE CLUSTER
b) CREATE PACKAGE
c) CREATE SCHEMA
d) All of the mentioned

47. Which of the following is known as the process of viewing cross-tab


with a fixed value of one attribute?
a) Dicing
b) Pivoting
c) Slicing
d) Both Pivoting and Dicing
View Answer
Answer: c
Explanation: Slice procedure takes one dimension from a cube and turns it
into a new sub-cube. Dice takes two or more dimensions from a cube and
creates a new sub-cube from them.
48. For designing a normal RDBMS which of the following normal form is
considered adequate?
a) 4NF
b) 3NF
c) 2NF
d) 5NF

Explanation: Because most 3NF tables are free of insertion, update,


and deletion anomalies, an RDBMS table is sometimes regarded as
“normalized” if it is in the Third Normal Form.
49. Which of the following is popular for applications such as storage of
log files in a database management system since it offers the best
write performance?
a) RAID level 0 - data stripping
b) RAID level 1- disk mirroring with block striping
c) RAID level 2 - bit-level stripping
d) RAID level 3 - byte-level striping with dedicated parity

Explanation: RAID level 0 refers to data stripping. RAID level 1 refers


to disk mirroring with block striping. RAID level 2 refers to bit-level
stripping and RAID level 3 refers to byte-level striping with dedicated
parity.
51. The oldest DB model is _______________
a) Network
b) Physical
c) Hierarchical
d) Relational

53. Which of the following establishes a top-to-bottom relationship among


the items?
a) Relational schema
b) Network schema
c) Hierarchical schema

54. A major goal of the db system is to minimize the number of block


transfers between the disk and memory. Which of the following helps in
achieving this goal?
a) Secondary storage
b) Storage
c) Catalog
d) Buffer

55. What happens if a piece of data is stored in two places in the db?
a) Storage space is wasted & Changing the data in one spot will cause
data inconsistency

56. The logical design, and the snapshot of the data at a given instant
in time is known as?
a) Instance & Relation
b) Relation & Schema
c) Domain & Schema
d) Schema & Instance

Database Questions and Answers – Relational Database


and Database Schema
1. A relational database consists of a collection of
a) Tables
b) Fields
c) Records
d) Keys
View Answer
Answer: a
Explanation: Fields are the column of the relation or tables. Records are
each row in a relation. Keys are the constraints in a relation.
2. A ________ in a table represents a relationship among a set of values.
a) Column
b) Key
c) Row
d) Entry
View Answer
Answer: c
Explanation: Column has only one set of values. Keys are constraints and
row is one whole set of attributes. Entry is just a piece of data.
3. The term _______ is used to refer to a row.
a) Attribute
b) Tuple
c) Field
d) Instance
View Answer
Answer: b
Explanation: Tuple is one entry of the relation with several attributes which
are fields.
advertisement
4. The term attribute refers to a ___________ of a table.
a) Record
b) Column
c) Tuple
d) Key
View Answer
Answer: b
Explanation: Attribute is a specific domain in the relation which has entries
of all tuples.
5. For each attribute of a relation, there is a set of permitted values, called
the ________ of that attribute.
a) Domain
b) Relation
c) Set
d) Schema
View Answer
Answer: a
Explanation: The values of the attribute should be present in the domain.
Domain is a set of values permitted.
Subscribe Now: DBMS Newsletter | Important Subjects Newsletters
6. Database __________ which is the logical design of the database, and
the database _______ which is a snapshot of the data in the database at a
given instant in time.
a) Instance, Schema
b) Relation, Schema
c) Relation, Domain
d) Schema, Instance
View Answer
Answer: d
Explanation: Instance is an instance of time and schema is a
representation.
7. Course(course_id,sec_id,semester)
Here the course_id,sec_id and semester are __________ and course is a
_________
a) Relations, Attribute
b) Attributes, Relation
c) Tuple, Relation
d) Tuple, Attributes
View Answer
Answer: b
Explanation: The relation course has a set of attributes
course_id,sec_id,semester .
8. Department (dept name, building, budget) and Employee (employee_id,
name, dept name, salary)
Here the dept_name attribute appears in both the relations. Here using
common attributes in relation schema is one way of relating ___________
relations.
a) Attributes of common
b) Tuple of common
c) Tuple of distinct
d) Attributes of distinct
View Answer
Answer: c
Explanation: Here the relations are connected by the common attributes.
9. A domain is atomic if elements of the domain are considered to be
____________ units.
a) Different
b) Indivisbile
c) Constant
d) Divisible
View Answer
Answer: b
Explanation: None.
10. The tuples of the relations can be of ________ order.
a) Any
b) Same
c) Sorted
d) Constant
View Answer
Answer: a
Explanation: The values only count. The order of the tuples does not
matter.
Database Questions and Answers – Keys
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Keys”.

1. Which one of the following is a set of one or more attributes taken


collectively to uniquely identify a record?
a) Candidate key
b) Sub key
c) Super key
d) Foreign key
View Answer
Answer: c
Explanation: Super key is the superset of all the keys in a relation.
2. Consider attributes ID, CITY and NAME. Which one of this can be
considered as a super key?
a) NAME
b) ID
c) CITY
d) CITY, ID
View Answer
Answer: b
Explanation: Here the id is the only attribute which can be taken as a key.
Other attributes are not uniquely identified.
3. The subset of a super key is a candidate key under what condition?
a) No proper subset is a super key
b) All subsets are super keys
c) Subset is a super key
d) Each subset is a super key
View Answer
Answer: a
Explanation: The subset of a set cannot be the same set. Candidate key is
a set from a super key which cannot be the whole of the super set.
advertisement
4. A _____ is a property of the entire relation, rather than of the individual
tuples in which each tuple is unique.
a) Rows
b) Key
c) Attribute
d) Fields
View Answer
Answer: b
Explanation: Key is the constraint which specifies uniqueness.
5. Which one of the following attribute can be taken as a primary key?
a) Name
b) Street
c) Id
d) Department
View Answer
Answer: c
Explanation: The attributes name, street and department can repeat for
some tuples. But the id attribute has to be unique. So it forms a primary
key.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
6. Which one of the following cannot be taken as a primary key?
a) Id
b) Register number
c) Dept_id
d) Street
View Answer
Answer: d
Explanation: Street is the only attribute which can occur more than once.
7. An attribute in a relation is a foreign key if the _______ key from one
relation is used as an attribute in that relation.
a) Candidate
b) Primary
c) Super
d) Sub
View Answer
Answer: b
Explanation: The primary key has to be referred in the other relation to form
a foreign key in that relation.
8. The relation with the attribute which is the primary key is referenced in
another relation. The relation which has the attribute as a primary key is
called ______________
a) Referential relation
b) Referencing relation
c) Referenced relation
d) Referred relation
View Answer
Answer: c
Explanation: None.
9. The ______ is the one in which the primary key of one relation is used
as a normal attribute in another relation.
a) Referential relation
b) Referencing relation
c) Referenced relation
d) Referred relation
View Answer
Answer: c
Explanation: None.
10. A _________ integrity constraint requires that the values appearing in
specified attributes of any tuple in the referencing relation also appear in
specified attributes of at least one tuple in the referenced relation.
a) Referential
b) Referencing
c) Specific
d) Primary
View Answer
Answer: a
Explanation: A relation, say r1, may include among its attributes the
primary key of another relation, say r2. This attribute is called a foreign key
from r1, referencing r2. The relation r1 is also called the referencing relation
of the foreign key dependency, and r2 is called the referenced relation of
the foreign key.

Database Questions and Answers – Relational Query


Operations and Relational Operators
This set of Database MCQs focuses on “Relational Query Operations and
Relational Operators”.

1. Using which language can a user request information from a database?


a) Query
b) Relational
c) Structural
d) Compiler
View Answer
Answer: a
Explanation: Query language is a method through which the database
entries can be accessed.
2. Student(ID, name, dept name, tot_cred)
In this query which attributes form the primary key?
a) Name
b) Dept
c) Tot_cred
d) ID
View Answer
Answer: d
Explanation: The attributes name, dept and tot_cred can have same values
unlike ID.
3. Which one of the following is a procedural language?
a) Domain relational calculus
b) Tuple relational calculus
c) Relational algebra
d) Query language
View Answer
Answer: c
Explanation: Domain and Tuple relational calculus are non-procedural
language. Query language is a method through which database entries can
be accessed.
advertisement
ADVERTISEMENT
ADVERTISEMENT
4. The_____ operation allows the combining of two relations by merging
pairs of tuples, one from each relation, into a single tuple.
a) Select
b) Join
c) Union
d) Intersection
View Answer
Answer: b
Explanation: Join finds the common tuple in the relations and combines it.
5. The result which operation 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
View Answer
Answer: b
Explanation: Cartesian product is the multiplication of all the values in the
attributes.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
6. The _______operation performs a set union of two “similarly structured”
tables
a) Union
b) Join
c) Product
d) Intersect
View Answer
Answer: a
Explanation: Union just combines all the values of relations of same
attributes.
7. The most commonly used operation in relational algebra for projecting a
set of tuple from a relation is
a) Join
b) Projection
c) Select
d) Union
View Answer
Answer: c
Explanation: Select is used to view the tuples of the relation with or without
some constraints.
8. The _______ operator takes the results of two queries and returns only
rows that appear in both result sets.
a) Union
b) Intersect
c) Difference
d) Projection
View Answer
Answer: b
Explanation: The union operator gives the result which is the union of two
queries and difference is the one where query which is not a part of second
query.
9. A ________ is a pictorial depiction of the schema of a database that
shows the relations in the database, their attributes, and primary keys and
foreign keys.
a) Schema diagram
b) Relational algebra
c) Database diagram
d) Schema flow
View Answer
Answer: a
Explanation: None.
10. The _________ provides a set of operations that take one or more
relations as input and return a relation as an output.
a) Schematic representation
b) Relational algebra
c) Scheme diagram
d) Relation flow
View Answer
Answer: b

Database Questions and Answers – SQL Basics and SQL


Data Definition
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “SQL Basics and SQL Data Definition”.

1. Which one of the following is used to define the structure of the relation,
deleting relations and relating schemas?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
View Answer
Answer: b
Explanation: Data Definition language is the language which performs all
the operation in defining structure of relation.
2. Which one of the following provides the ability to query information from
the database and to insert tuples into, delete tuples from, and modify tuples
in the database?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
View Answer
Answer: a
Explanation: DML performs the change in the values of the relation.
3.

advertisement
ADVERTISEMENT
ADVERTISEMENT
CREATE TABLE employee (name VARCHAR, id INTEGER)
What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
View Answer
Answer: b
Explanation: Data Definition language is the language which performs all
the operation in defining structure of relation.
Subscribe Now: DBMS Newsletter | Important Subjects Newsletters
4.

SELECT * FROM employee


What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
View Answer
Answer: a
Explanation: Select operation just shows the required fields of the relation.
So it forms a DML.
5. The basic data type char(n) is a _____ length character string and
varchar(n) is _____ length character.
a) Fixed, equal
b) Equal, variable
c) Fixed, variable
d) Variable, equal
View Answer
Answer: c
Explanation: Varchar changes its length accordingly whereas char has a
specific length which has to be filled by either letters or spaces.
6. An attribute A of datatype varchar(20) has the value “Avi”. The attribute
B of datatype char(20) has value ”Reed”. Here attribute A has ____ spaces
and attribute B has ____ spaces.
a) 3, 20
b) 20, 4
c) 20, 20
d) 3, 4
View Answer
Answer: a
Explanation: Varchar changes its length accordingly whereas char has a
specific length which has to be filled by either letters or spaces.
7. To remove a relation from an SQL database, we use the ______
command.
a) Delete
b) Purge
c) Remove
d) Drop table
View Answer
Answer: d
Explanation: Drop table deletes the whole structure of the relation .purge
removes the table which cannot be obtained again.
8.

DELETE FROM r; //r - relation


This command performs which of the following action?
a) Remove relation
b) Clear relation entries
c) Delete fields
d) Delete rows
View Answer
Answer: b
Explanation: Delete command removes the entries in the table.
9.

INSERT INTO instructor VALUES (10211, ’Smith’,


’Biology’, 66000);
What type of statement is this?
a) Query
b) DML
c) Relational
d) DDL
View Answer
Answer: b
Explanation: The values are manipulated. So it is a DML.
10. Updates that violate __________ are disallowed.
a) Integrity constraints
b) Transaction control
c) Authorization
d) DDL constraints
View Answer
Answer: a
Explanation: Integrity constraint has to be maintained in the entries of the
relation.

Database Questions and Answers – SQL Queries


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “SQL Queries”.

1.

Name

Annie

Bob

Callie

Derek
Which of these query will display the the table given above ?
a) Select employee from name
b) Select name
c) Select name from employee
d) Select employee
View Answer
Answer: c
Explanation: The field to be displayed is included in select and the table is
included in the from clause.
2. Here which of the following displays the unique values of the column?

advertisement
ADVERTISEMENT
ADVERTISEMENT
SELECT ________ dept_name
FROM instructor;
a) All
b) From
c) Distinct
d) Name
View Answer
Answer: c
Explanation: Distinct keyword selects only the entries that are unique.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
3. The ______ clause allows us to select only those rows in the result
relation of the ____ clause that satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where
View Answer
Answer: a
Explanation: Where selects the rows on a particular condition. From gives
the relation which involves the operation.
4. The query given below will not give an error. Which one of the following
has to be replaced to get the desired output?

SELECT ID, name, dept name, salary * 1.1


WHERE instructor;
a) Salary*1.1
b) ID
c) Where
d) Instructor
View Answer
Answer: c
Explanation: Where selects the rows on a particular condition. From gives
the relation which involves the operation. Since Instructor is a relation it has
to have from clause.
5. The ________ clause is used to list the attributes desired in the result of
a query.
a) Where
b) Select
c) From
d) Distinct
View Answer
Answer: b
Explanation: None
6. This Query can be replaced by which one of the following?

SELECT name, course_id


FROM instructor, teaches
WHERE instructor_ID= teaches_ID;
a) Select name,course_id from teaches,instructor where
instructor_id=course_id;
b) Select name, course_id from instructor natural join teaches;
c) Select name, course_id from instructor;
d) Select course_id from instructor join teaches;
View Answer
Answer: b
Explanation: Join clause joins two tables by matching the common column.
7.

SELECT * FROM employee WHERE salary>10000 AND


dept_id=101;
Which of the following fields are displayed as output?
a) Salary, dept_id
b) Employee
c) Salary
d) All the field of employee relation
View Answer
Answer: d
Explanation: Here * is used to select all the fields of the relation.
8.

Employee_id Name Salary

1001 Annie 6000

1009 Ross 4500

1018 Zeith 7000


This is Employee table.
Which of the following employee_id will be displayed for the given query?

SELECT * FROM employee WHERE employee_id>1009;


a) 1009, 1001, 1018
b) 1009, 1018
c) 1001
d) 1018
View Answer
Answer: d
Explanation: Greater than symbol does not include the given value unlike
>=.
9. Which of the following statements contains an error?
a) Select * from emp where empid = 10003;
b) Select empid from emp where empid = 10006;
c) Select empid from emp;
d) Select empid where empid = 1009 and lastname = ‘GELLER’;
View Answer
Answer: d
Explanation: This query do not have from clause which specifies the
relation from which the values has to be selected.
10. In the given query which of the keyword has to be inserted?

INSERT INTO employee _____ (1002,Joey,2000);


a) Table
b) Values
c) Relation
d) Field
View Answer
Answer: b
Explanation: Value keyword has to be used to insert the values into the
table.

Database Questions and Answers – Basic SQL Operations


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Basic SQL Operations”.

1.

SELECT name ____ instructor name, course id


FROM instructor, teaches
WHERE instructor.ID= teaches.ID;
Which keyword must be used here to rename the field name?
a) From
b) Rename
c) As
d) Join
View Answer
Answer: c
Explanation: As keyword is used to rename.
advertisement
2.

SELECT * FROM employee WHERE dept_name="Comp Sci";


In the SQL given above there is an error . Identify the error.
a) Dept_name
b) Employee
c) “Comp Sci”
d) From
View Answer
Answer: c
Explanation: For any string operations single quoted(‘) must be used to
enclose.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
3.

SELECT emp_name
FROM department
WHERE dept_name LIKE ’ _____ Computer Science’;
Which one of the following has to be added into the blank to select the
dept_name which has Computer Science as its ending string?
a) %
b) _
c) ||
d) $
View Answer
Answer: a
Explanation: The % character matches any substring.
4. ’_ _ _ ’ matches any string of ______ three characters. ’_ _ _ %’ matches
any string of at ______ three characters.
a) Atleast, Exactly
b) Exactly, Atleast
c) Atleast, All
d) All, Exactly
View Answer
Answer: b
Explanation: None.
5.

SELECT name
FROM instructor
WHERE dept name = ’Physics’
ORDER BY name;
By default, the order by clause lists items in ______ order.
a) Descending
b) Any
c) Same
d) Ascending
View Answer
Answer: d
Explanation: Specification of descending order is essential but it not for
ascending.
6.

SELECT *
FROM instructor
ORDER BY salary ____, name ___;
To display the salary from greater to smaller and name in ascending order
which of the following options should be used?
a) Ascending, Descending
b) Asc, Desc
c) Desc, Asc
d) Descending, Ascending
View Answer
Answer: c
Explanation: None.
7.

SELECT name
FROM instructor
WHERE salary <= 100000 AND salary >= 90000;
This query can be replaced by which of the following ?
a)

SELECT name
FROM instructor
WHERE salary BETWEEN 90000 AND 100000;
b)

SELECT name
FROM employee
WHERE salary <= 90000 AND salary>=100000;
c)

SELECT name
FROM employee
WHERE salary BETWEEN 90000 AND 100000;
d)

SELECT name
FROM instructor
WHERE salary BETWEEN 100000 AND 90000;
View Answer
Answer: a
Explanation: SQL includes a between comparison operator to simplify
where clauses that specify that a value be less than or equal to some value
and greater than or equal to some other value.

8.

SELECT instructor.*
FROM instructor, teaches
WHERE instructor.ID= teaches.ID;
This query does which of the following operation?
a) All attributes of instructor and teaches are selected
b) All attributes of instructor are selected on the given condition
c) All attributes of teaches are selected on given condition
d) Only the some attributes from instructed and teaches are selected
View Answer
Answer: b
Explanation: The asterisk symbol “ * ” can be usedin the select clause to
denote “all attributes.”
9. In SQL the spaces at the end of the string are removed by _______
function.
a) Upper
b) String
c) Trim
d) Lower
View Answer
Answer: c
Explanation: The syntax of trim is Trim(s); where s-string.
10. _____ operator is used for appending two strings.
a) &
b) %
c) ||
d) _
View Answer
Answer: c
Explanation: || is the concatenation operator

Database Questions and Answers – Set Operations


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Set Operations”.

1. The union operation is represented by


a) ∩
b) U
c) –
d) *
View Answer
Answer: b
Explanation: Union operator combines the relations.

2. The intersection operator is used to get the _____ tuples.


a) Different
b) Common
c) All
d) Repeating
View Answer
Answer: b
Explanation: Intersection operator ignores unique tuples and takes only
common ones.
3. The union operation automatically __________ unlike the select clause.
a) Adds tuples
b) Eliminates unique tuples
c) Adds common tuples
d) Eliminates duplicate
View Answer
Answer: d
Explanation: None.

advertisement

4. If we want to retain all duplicates, we must write ________ in place of


union.
a) Union all
b) Union some
c) Intersect all
d) Intersect some
View Answer
Answer: a
Explanation: Union all will combine all the tuples including duplicates.

5.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.


Participate Now!
(SELECT course id
FROM SECTION
WHERE semester = ’Fall’ AND YEAR= 2009)
EXCEPT
(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010);
This query displays
a) Only tuples from second part
b) Only tuples from the first part which has the tuples from second part
c) Tuples from both the parts
d) Tuples from first part which do not have second part
View Answer
Answer: d
Explanation: Except keyword is used to ignore the values.

6. For like predicate which of the following is true.

i) % matches zero OF more characters.


ii) _ matches exactly one CHARACTER.
a) i-only
b) ii-only
c) i & ii
d) None of the mentioned
View Answer
Answer: c
Explanation: The % wildcard matches zero or more characters, while the _
wildcard matches exactly one character. Together, they offer flexibility and
precision in pattern matching within the like predicate.

7. The number of attributes in relation is called as its


a) Cardinality
b) Degree
c) Tuples
d) Entity
View Answer
Answer: b
Explanation: None.

8. _____ clause is an additional filter that is applied to the result.


a) Select
b) Group-by
c) Having
d) Order by
View Answer
Answer: c
Explanation: Having is used to provide additional aggregate filtration to the
query.

9. _________ joins are SQL server default


a) Outer
b) Inner
c) Equi
d) None of the mentioned
View Answer
Answer: b
Explanation: It is optional to give the inner keyword with the join as it is
default.

10. The _____________ is essentially used to search for patterns in target


string.
a) Like Predicate
b) Null Predicate
c) In Predicate
d) Out Predicate
View Answer
Answer: a

Database Questions and Answers – Null Values Operations


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Null Values Operations”.

1. A _____ indicates an absent value that may exist but be unknown or that
may not exist at all.
a) Empty tuple
b) New value
c) Null value
d) Old value
View Answer
Answer: c
Explanation: None.

2. If the attribute phone number is included in the relation all the values
need not be entered into the phone number column. This type of entry is
given as
a) 0
b) –
c) Null
d) Empty space
View Answer
Answer: c
Explanation: Null is used to represent the absence of a value.

3. The predicate in a where clause can involve Boolean operations such as


and. The result of true and unknown is_______ false and unknown is
_____ while unknown and unknown is _____
a) Unknown, unknown, false
b) True, false, unknown
c) True, unknown, unknown
d) Unknown, false, unknown
View Answer
Answer: d
Explanation: None.

advertisement

4.

SELECT name
FROM instructor
WHERE salary IS NOT NULL;
Selects
a) Tuples with null value
b) Tuples with no null values
c) Tuples with any salary
d) All of the mentioned
View Answer
Answer: b
Explanation: Not null constraint removes the tpules of null values.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.


Participate Now!

5. In an employee table to include the attributes whose value always have


some value which of the following constraint must be used?
a) Null
b) Not null
c) Unique
d) Distinct
View Answer
Answer: b
Explanation: Not null constraint removes the tuples of null values.

6. Using the ______ clause retains only one copy of such identical tuples.
a) Null
b) Unique
c) Not null
d) Distinct
View Answer
Answer: d
Explanation: Unique is a constraint.

7.

CREATE TABLE employee (id INTEGER,name


VARCHAR(20),salary NOT NULL);
INSERT INTO employee VALUES (1005,Rach,0);
INSERT INTO employee VALUES (1007,Ross, );
INSERT INTO employee VALUES (1002,Joey,335);
Some of these insert statements will produce an error. Identify the
statement.
a) Insert into employee values (1005,Rach,0);
b) Insert into employee values (1002,Joey,335);
c) Insert into employee values (1007,Ross, );
d) None of the mentioned
View Answer
Answer: c
Explanation: Not null constraint is specified which means sone value (can
include 0 also) should be given.

8. The primary key must be


a) Unique
b) Not null
c) Both Unique and Not null
d) Either Unique or Not null
View Answer
Answer: c
Explanation: Primary key must satisfy unique and not null condition for
sure.
9. You attempt to query the database with this command:

SELECT nvl (100 / quantity, NONE)


FROM inventory;
Why does this statement cause an error when QUANTITY values are null?
a) The expression attempts to divide by a null value
b) The data types in the conversion function are incompatible
c) The character string none should be enclosed in single quotes (‘ ‘)
d) A null value used in an expression cannot be converted to an actual
value
View Answer
Answer: a
Explanation: The expression attempts to divide by a null value is erroneous
in sql.

10. The result of _____unknown is unknown.


a) Xor
b) Or
c) And
d) Not
View Answer
Answer: d

Database Questions and Answers – Aggregate Functions


and Nested Subqueries – 1
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Aggregate Functions and Nested Subqueries – 1”.

1. Aggregate functions are functions that take a ___________ as input and


return a single value.
a) Collection of values
b) Single value
c) Aggregate value
d) Both Collection of values & Single value
View Answer
Answer: a
Explanation: None.

2.
SELECT __________
FROM instructor
WHERE dept name= ’Comp. Sci.’;
Which of the following should be used to find the mean of the salary ?
a) Mean(salary)
b) Avg(salary)
c) Sum(salary)
d) Count(salary)
View Answer
Answer: b
Explanation: Avg() is used to find the mean of the values.

advertisement

ADVERTISEMENT

ADVERTISEMENT

3.

Note: Join free Sanfoundry classes at Telegram or Youtube


SELECT COUNT (____ ID)
FROM teaches
WHERE semester = ’Spring’ AND YEAR = 2010;
If we do want to eliminate duplicates, we use the keyword ______in the
aggregate expression.
a) Distinct
b) Count
c) Avg
d) Primary key
View Answer
Answer: a
Explanation: Distinct keyword is used to select only unique items from the
relation.

4. All aggregate functions except _____ ignore null values in their input
collection.
a) Count(attribute)
b) Count(*)
c) Avg
d) Sum
View Answer
Answer: b
Explanation: * is used to select all values including null.

5. A Boolean data type that can take values true, false, and________
a) 1
b) 0
c) Null
d) Unknown
View Answer
Answer: d
Explanation: Unknown values do not take null value but it is not known.

6. The ____ connective tests for set membership, where the set is a
collection of values produced by a select clause. The ____ connective tests
for the absence of set membership.
a) Or, in
b) Not in, in
c) In, not in
d) In, or
View Answer
Answer: c
Explanation: In checks, if the query has the value but not in checks if it
does not have the value.

7. Which of the following should be used to find all the courses taught in the
Fall 2009 semester but not in the Spring 2010 semester .
a)

SELECT DISTINCT course id


FROM SECTION
WHERE semester = ’Fall’ AND YEAR= 2009 AND
course id NOT IN (SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010);
b)
SELECT DISTINCT course_id
FROM instructor
WHERE name NOT IN (’Fall’, ’Spring’);
c)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
d)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT
course id, sec id, semester, YEAR
FROM teaches
WHERE teaches.ID= 10101);
View Answer

Answer: a
Explanation: None.

8. The phrase “greater than at least one” is represented in SQL by _____


a) < all
b) < some
c) > all
d) > some
View Answer
Answer: d
Explanation: >some takes atlest one value above it .

9. Which of the following is used to find all courses taught in both the Fall
2009 semester and in the Spring 2010 semester .
a)

SELECT course id
FROM SECTION AS S
WHERE semester = ’Fall’ AND YEAR= 2009 AND
EXISTS (SELECT *
FROM SECTION AS T
WHERE semester = ’Spring’ AND YEAR= 2010 AND
S.course id= T.course id);
b)

SELECT name
FROM instructor
WHERE salary > SOME (SELECT salary
FROM instructor
WHERE dept name = ’Biology’);
c)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT
course id, sec id, semester, YEAR
FROM teaches
WHERE teaches.ID= 10101);
d)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
View Answer

Answer: a
Explanation: None.

10. We can test for the nonexistence of tuples in a subquery by using the
_____ construct.
a) Not exist
b) Not exists
c) Exists
d) Exist
View Answer
Answer: b
Database Questions and Answers – Aggregate Functions
and Nested Subqueries – 2
This set of Database Interview Questions and Answers focuses on
“Aggregate Functions and Nested Subqueries – 2”.

1.

SELECT dept_name, ID, avg (salary)


FROM instructor
GROUP BY dept_name;
This statement IS erroneous because
a) Avg(salary) should not be selected
b) Dept_id should not be used in group by clause
c) Misplaced group by clause
d) Group by clause is not valid in this query
View Answer
Answer: b
Explanation: Any attribute that is not present in the group by clause must
appear only inside an aggregate function if it appears in the select clause,
otherwise the query is treated as erroneous.

advertisement

2. SQL applies predicates in the _______ clause after groups have been
formed, so aggregate functions may be used.
a) Group by
b) With
c) Where
d) Having
View Answer
Answer: d
Explanation: The Having clause in SQL is used to apply predicates after
groups have been formed using the Group By clause. This allows
aggregate functions to be used and filters the grouped data based on
specified conditions.

3. Aggregate functions can be used in the select list or the_______clause


of a select statement or subquery. They cannot be used in a ______
clause.
a) Where, having
b) Having, where
c) Group by, having
d) Group by, where
View Answer
Answer: b
Explanation: To include aggregate functions having clause must be
included after where.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.


Participate Now!

4. The ________ keyword is used to access attributes of preceding tables


or subqueries in the from clause.
a) In
b) Lateral
c) Having
d) With
View Answer
Answer: b
Explanation:
Eg : SELECT name, salary, avg salary
FROM instructor I1, lateral (SELECT
avg(salary) AS avg salary
FROM instructor I2
WHERE I2.dept name= I1.dept name);
Without the lateral clause, the subquery cannot access the correlation
variable
I1 from the outer query.

5. Which of the following creates a temporary relation for the query on


which it is defined?
a) With
b) From
c) Where
d) Select
View Answer
Answer: a
Explanation: The with clause provides a way of defining a temporary
relation whose definition is available only to the query in which the with
clause occurs.

6.

WITH max_budget (VALUE) AS


(SELECT MAX(budget)
FROM department)
SELECT budget
FROM department, max_budget
WHERE department.budget = MAX budget.value;
In the query given above which one of the following is a temporary relation?
a) Budget
b) Department
c) Value
d) Max_budget
View Answer
Answer: d
Explanation: With clause creates a temporary relation.

7. Subqueries cannot:
a) Use group by or group functions
b) Retrieve data from a table different from the one in the outer query
c) Join tables
d) Appear in select, update, delete, insert statements.
View Answer
Answer: c
Explanation: None.

8. Which of the following is not an aggregate function?


a) Avg
b) Sum
c) With
d) Min
View Answer
Answer: c
Explanation: With is used to create temporary relation and its not an
aggregate function.

9. The EXISTS keyword will be true if:


a) Any row in the subquery meets the condition only
b) All rows in the subquery fail the condition only
c) Both of these two conditions are met
d) Neither of these two conditions is met
View Answer
Answer: a
Explanation: EXISTS keyword checks for existance of a condition.

10. How can you find rows that do not match some specified condition?
a) EXISTS
b) Double use of NOT EXISTS
c) NOT EXISTS
d) None of the mentioned
View Answer
Answer: b

Database Questions and Answers – Modification of


Database
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Modification of Database”.

1. A Delete command operates on ______ relation.


a) One
b) Two
c) Several
d) Null
View Answer
Answer: a
Explanation: Delete can delete from only one table at a time.

2.

Delete from r where P;


The above command
a) Deletes a particular tuple from the relation
b) Deletes the relation
c) Clears all entries from the relation
d) All of the mentioned
View Answer
Answer: a
Explanation: Here P gives the condition for deleting specific rows.

advertisement

3. Which one of the following deletes all the entries but keeps the structure
of the relation.
a) Delete from r where P;
b) Delete from instructor where dept name= ’Finance’;
c) Delete from instructor where salary between 13000 and 15000;
d) Delete from instructor;
View Answer
Answer: d
Explanation: Absence of condition deletes all rows.

4. Which of the following is used to insert a tuple from another relation?


a)

Note: Join free Sanfoundry classes at Telegram or Youtube


INSERT INTO course (course id, title, dept name,
credits)
VALUES (’CS-437’, ’DATABASE Systems’, ’Comp. Sci.’,
4);
b)

INSERT INTO instructor


SELECT ID, name, dept name, 18000
FROM student
WHERE dept name = ’Music’ AND tot cred > 144;
c)

INSERT INTO course VALUES (’CS-437’, ’DATABASE


Systems’, ’Comp. Sci.’, 4);
d) Not possible
View Answer
Answer: b
Explanation: Using select statement in insert will include rows which are the
result of the selection.

5. Which of the following deletes all tuples in the instructor relation for those
instructors associated with a department located in the Watson building
which is in department relation.
a)

DELETE FROM instructor


WHERE dept_name IN 'Watson';
b)

DELETE FROM department


WHERE building='Watson';
c)

DELETE FROM instructor


WHERE dept_name IN (SELECT dept name
FROM department
WHERE building = ’Watson’);
d) None of the mentioned
View Answer
Answer: c
Explanation: The query must include building=watson condition to filter the
tuples.

6.

UPDATE instructor
_____ salary= salary * 1.05;
Fill in with correct keyword to update the instructor relation.
a) Where
b) Set
c) In
d) Select
View Answer
Answer: b
Explanation: Set is used to update the particular value.

7. _________ are useful in SQL update statements, where they can be


used in the set clause.
a) Multiple queries
b) Sub queries
c) Update
d) Scalar subqueries
View Answer
Answer: d
Explanation: None.

8. The problem of ordering the update in multiple updates is avoided using


a) Set
b) Where
c) Case
d) When
View Answer
Answer: c
Explanation: The case statements can add the order of updating tuples.

9. Which of the following is the correct format for case statements.


a)

CASE
WHEN pred1 ... result1
WHEN pred2 ... result2
. . .
WHEN predn ... resultn
ELSE result0
END
b)

CASE
WHEN pred1 THEN result1
WHEN pred2 THEN result2
. . .
WHEN predn THEN resultn
ELSE result0
END
c)

CASE
WHEN pred1 THEN result1
WHEN pred2 THEN result2
. . .
WHEN predn THEN resultn
ELSE result0
d) All of the mentioned
View Answer
Answer: b
Explanation: None.

10. Which of the following relation updates all instructors with salary over
$100,000 receive a 3 percent raise, whereas all others receive a 5 percent
raise.
a)

UPDATE instructor
SET salary = salary * 1.03
WHERE salary > 100000;
UPDATE instructor
SET salary = salary * 1.05
WHERE salary <= 100000;
b)

UPDATE instructor
SET salary = salary * 1.05
WHERE salary < (SELECT avg (salary)
FROM instructor);
c)

UPDATE instructor
SET salary = CASE
WHEN salary <= 100000 THEN salary * 1.03
ELSE salary * 1.05
END
d) None of the mentioned
View Answer
Answer: a
Explanation: The order of the two update statements is important. If we
changed the order of the two statements, an instructor with a salary just
under $100,000 would receive an over 8 percent raise. SQL provides a
case construct that we can use to perform both the updates with a single
update statement, avoiding the problem with the order of updates.

Database Questions and Answers – Join Expressions


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Join Expressions”.

1. The____condition allows a general predicate over the relations being


joined.
a) On
b) Using
c) Set
d) Where
View Answer
Answer: a
Explanation: On gives the condition for the join expression.

2. Which of the join operations do not preserve non matched tuples?


a) Left outer join
b) Right outer join
c) Inner join
d) Natural join
View Answer
Answer: c
Explanation: INNER JOIN: Returns all rows when there is at least one
match in BOTH tables.

3.

advertisement
SELECT *
FROM student JOIN takes USING (ID);
The above query is equivalent to
a)
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.
Participate Now!
SELECT *
FROM student INNER JOIN takes USING (ID);
b)

SELECT *
FROM student OUTER JOIN takes USING (ID);
c)

SELECT *
FROM student LEFT OUTER JOIN takes USING (ID);
d) None of the mentioned
View Answer
Answer: a
Explanation: Join can be replaced by inner join.

4. What type of join is needed when you wish to include rows that do not
have matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the mentioned
View Answer
Answer: c
Explanation: An outer join does not require each record in the two joined
tables to have a matching record..

5. How many tables may be included with a join?


a) One
b) Two
c) Three
d) All of the mentioned
View Answer
Answer: d
Explanation: Join can combine multiple tables.

6. Which are the join types in join condition:


a) Cross join
b) Natural join
c) Join with USING clause
d) All of the mentioned
View Answer
Answer: d
Explanation: There are totally four join types in SQL.

7. How many join types in join condition:


a) 2
b) 3
c) 4
d) 5
View Answer
Answer: d
Explanation: Types are inner join, left outer join, right outer join, full join,
cross join.

8. Which join refers to join records from the right table that have no
matching key in the left table are include in the result set:
a) Left outer join
b) Right outer join
c) Full outer join
d) Half outer join
View Answer
Answer: b
Explanation: RIGHT OUTER JOIN: Return all rows from the right table and
the matched rows from the left table.

9. The operation which is not considered a basic operation of relational


algebra is
a) Join
b) Selection
c) Union
d) Cross product
View Answer
Answer: a
Explanation: None.
10. In SQL the statement select * from R, S is equivalent to
a) Select * from R natural join S
b) Select * from R cross join S
c) Select * from R union join S
d) Select * from R inner join S
View Answer
Answer: b

Database Questions and Answers – Views


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Views”.

1. Which of the following creates a virtual relation for storing the query?
a) Function
b) View
c) Procedure
d) None of the mentioned
View Answer
Answer: b
Explanation: Any such relation that is not part of the logical model, but is
made visible to a user as a virtual relation, is called a view.

2. Which of the following is the syntax for views where v is view name?
a) Create view v as “query name”;
b) Create “query expression” as view;
c) Create view v as “query expression”;
d) Create view “query expression”;
View Answer
Answer: c
Explanation: <query expression> is any legal query expression. The view
name is represented by v.

3.

advertisement

ADVERTISEMENT

ADVERTISEMENT
SELECT course_id
FROM physics_fall_2009
WHERE building= ’Watson’;
Here the tuples are selected from the view.Which one denotes the view.
a) Course_id
b) Watson
c) Building
d) physics_fall_2009
View Answer
Answer: c
Explanation: View names may appear in a query any place where a relation
name may appear.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.


Participate Now!

4. Materialised views make sure that


a) View definition is kept stable
b) View definition is kept up-to-date
c) View definition is verified for error
d) View is deleted after specified time
View Answer
Answer: b
Explanation: None.

5. Updating the value of the view


a) Will affect the relation from which it is defined
b) Will not change the view definition
c) Will not affect the relation from which it is defined
d) Cannot determine
View Answer
Answer: a
Explanation: None.

6. SQL view is said to be updatable (that is, inserts, updates or deletes can
be applied on the view) if which of the following conditions are satisfied by
the query defining the view?
a) The from clause has only one database relation
b) The query does not have a group by or having clause
c) The select clause contains only attribute names of the relation and does
not have any expressions, aggregates, or distinct specification
d) All of the mentioned
View Answer
Answer: d
Explanation: All of the conditions must be satisfied to update the view in
sql.

7. Which of the following is used at the end of the view to reject the tuples
which do not satisfy the condition in where clause?
a) With
b) Check
c) With check
d) All of the mentioned
View Answer
Answer: c
Explanation: Views can be defined with a with check option clause at the
end of the view definition; then, if a tuple inserted into the view does not
satisfy the view’s where clause condition, the insertion is rejected by the
database system.

8. Consider the two relations instructor and department


Instructor:

ID Name Dept_name Salary

1001 Ted Finance 10000

1002 Bob Music 20000

1003 Ron Physics 50000

Department:

Dept_name Building Budget


Biology Watson 40000

Chemistry Painter 30000

Music Taylor 50000

Which of the following is used to create view for these relations together?
a)

CREATE VIEW instructor_info AS


SELECT ID, name, building
FROM instructor, department
WHERE instructor.dept name= department.dept name;
b)

CREATE VIEW instructor_info


SELECT ID, name, building
FROM instructor, department;
c)

CREATE VIEW instructor_info AS


SELECT ID, name, building
FROM instructor;
d)

CREATE VIEW instructor_info AS


SELECT ID, name, building
FROM department;
View Answer

Answer: a
Explanation: None.

9. For the view Create view instructor_info as


SELECT ID, name, building
FROM instructor, department
WHERE instructor.dept name=
department.dept name;
If we insert tuple into the view as insert into instructor info values (’69987’,
’White’, ’Taylor’);
What will be the values of the other attributes in instructor and department
relations?
a) Default value
b) Null
c) Error statement
d) 0
View Answer
Answer: b
Explanation: The values take null if there is no constraint in the attribute
else it is an Erroneous statement.

10.

CREATE VIEW faculty AS


SELECT ID, name, dept name
FROM instructor;
Find the error in this query.
a) Instructor
b) Select
c) View …as
d) None of the mentioned
View Answer
Answer: d
Explanation: Syntax is – create view v as <query expression>;.

Database Questions and Answers – Transactions


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Transactions”.

1. A _________ consists of a sequence of query and/or update statements.


a) Transaction
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: a
Explanation: Transaction is a set of operation until commit.

2. Which of the following makes the transaction permanent in the


database?
a) View
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: b
Explanation: Commit work commits the current transaction.

3. In order to undo the work of transaction after last commit which one
should be used?
a) View
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: c
Explanation: Rollback work causes the current transaction to be rolled
back; that is, it undoes all the updates performed by the SQL statements in
the transaction.

advertisement

4. Consider the following action:

TRANSACTION.....
Commit;
ROLLBACK;
What does Rollback do?
a) Undoes the transactions before commit
b) Clears all transactions
c) Redoes the transactions before commit
d) No action
View Answer
Answer: d
Explanation: Once a transaction has executed commit work, its effects can
no longer be undone by rollback work.

Subscribe Now: DBMS Newsletter | Important Subjects Newsletters

5. In case of any shut down during transaction before commit which of the
following statement is done automatically?
a) View
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: c
Explanation: Once a transaction has executed commit work, its effects can
no longer be undone by rollback work.

6. In order to maintain the consistency during transactions, database


provides
a) Commit
b) Atomic
c) Flashback
d) Retain
View Answer
Answer: b
Explanation: By atomic, either all the effects of the transaction are reflected
in the database, or none are (after rollback).

7. Transaction processing is associated with everything below except


a) Conforming an action or triggering a response
b) Producing detail summary or exception report
c) Recording a business activity
d) Maintaining a data
View Answer
Answer: a
Explanation: None.
8. A transaction completes its execution is said to be
a) Committed
b) Aborted
c) Rolled back
d) Failed
View Answer
Answer: a
Explanation: A complete transaction always commits.

9. Which of the following is used to get back all the transactions back after
rollback?
a) Commit
b) Rollback
c) Flashback
d) Redo
View Answer
Answer: c
Explanation: None.

10. ______ will undo all statements up to commit?


a) Transaction
b) Flashback
c) Rollback
d) Abort
View Answer
Answer: c
Explanation: Flashback will undo all the statements and Abort will terminate
the operation.

Database Questions and Answers – Integrity Constraints


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Integrity Constraints”.

1. To include integrity constraint in an existing relation use :


a) Create table
b) Modify table
c) Alter table
d) Drop table
View Answer
Answer: c
Explanation: SYNTAX – alter table table-name add constraint, where
constraint can be any constraint on the relation.

2. Which of the following is not an integrity constraint?


a) Not null
b) Positive
c) Unique
d) Check ‘predicate’
View Answer
Answer: b
Explanation: Positive is a value and not a constraint.

3.

advertisement
CREATE TABLE Employee(Emp_id NUMERIC NOT NULL, Name
VARCHAR(20) , dept_name VARCHAR(20), Salary NUMERIC
UNIQUE(Emp_id,Name));
INSERT INTO Employee VALUES(1002, Ross, CSE, 10000)
INSERT INTO Employee VALUES(1006,Ted,Finance, );
INSERT INTO Employee VALUES(1002,Rita,Sales,20000);
What will be the result of the query?
a) All statements executed
b) Error in create statement
c) Error in insert into Employee values(1006,Ted,Finance, );
d) Error in insert into Employee values(1008,Ross,Sales,20000);
View Answer
Answer: d
Explanation: The not null specification prohibits the insertion of a null value
for the attribute.
The unique specification says that no two tuples in the relation can be
equal on all the listed attributes.

4.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.


Participate Now!
CREATE TABLE Manager(ID NUMERIC,Name VARCHAR(20),budget
NUMERIC,Details VARCHAR(30));
Inorder to ensure that the value of budget is non-negative which of the
following should be used?
a) Check(budget>0)
b) Check(budget<0)
c) Alter(budget>0)
d) Alter(budget<0)
View Answer
Answer: a
Explanation: A common use of the check clause is to ensure that attribute
values satisfy specified conditions, in effect creating a powerful type
system.

5. Foreign key is the one in which the ________ of one relation is


referenced in another relation.
a) Foreign key
b) Primary key
c) References
d) Check constraint
View Answer
Answer: b
Explanation: The foreign-key declaration specifies that for each course
tuple, the department name specified in the tuple must exist in the
department relation.

6.

CREATE TABLE course


( . . .
FOREIGN KEY (dept name) REFERENCES department
. . . );
Which of the following is used to delete the entries in the referenced table
when the tuple is deleted in course table?
a) Delete
b) Delete cascade
c) Set null
d) All of the mentioned
View Answer
Answer: b
Explanation: The delete “cascades” to the course relation, deletes the tuple
that refers to the department that was deleted.

7. Domain constraints, functional dependency and referential integrity are


special forms of _________
a) Foreign key
b) Primary key
c) Assertion
d) Referential constraint
View Answer
Answer: c
Explanation: An assertion is a predicate expressing a condition we wish the
database to always satisfy.

8. Which of the following is the right syntax for the assertion?


a) Create assertion ‘assertion-name’ check ‘predicate’;
b) Create assertion check ‘predicate’ ‘assertion-name’;
c) Create assertions ‘predicates’;
d) All of the mentioned
View Answer
Answer: a
Explanation: None.

9. Data integrity constraints are used to:


a) Control who is allowed access to the data
b) Ensure that duplicate records are not entered into the table
c) Improve the quality of data entered for a specific property (i.e., table
column)
d) Prevent users from changing the values stored in the table
View Answer
Answer: c
Explanation: None.

10. Which of the following can be addressed by enforcing a referential


integrity constraint?
a) All phone numbers must include the area code
b) Certain fields are required (such as the email address, or phone number)
before the record is accepted
c) Information on the customer must be known before anything can be sold
to that customer
d) When entering an order quantity, the user must input a number and not
some text (i.e., 12 rather than ‘a dozen’)
View Answer
Answer: c
Explanation: The information can be referred to and obtained.

Database Questions and Answers – SQL Data Types and


Schemas
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “SQL Data Types and Schemas”.

1. Dates must be specified in the format


a) mm/dd/yy
b) yyyy/mm/dd
c) dd/mm/yy
d) yy/dd/mm
View Answer
Answer: b
Explanation: yyyy/mm/dd is the default format in sql.

2. A ________ on an attribute of a relation is a data structure that allows


the database system to find those tuples in the relation that have a
specified value for that attribute efficiently, without scanning through all the
tuples of the relation.
a) Index
b) Reference
c) Assertion
d) Timestamp
View Answer
Answer: a
Explanation: Index is the reference to the tuples in a relation.

3.

Create index studentID_index on student(ID);


advertisement

ADVERTISEMENT

ADVERTISEMENT

Here which one denotes the relation for which index is created?
a) StudentID_index
b) ID
c) StudentID
d) Student
View Answer
Answer: d
Explanation: The statement creates an index named studentID index on the
attribute ID of the relation student.

4. Which of the following is used to store movie and image files?


a) Clob
b) Blob
c) Binary
d) Image
View Answer
Answer: b
Explanation: SQL therefore provides large-object data types for character
data (clob) and binary data (blob). The letters “lob” in these data types
stand for “Large OBject”.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects.


Participate Now!

5. The user defined data type can be created using


a) Create datatype
b) Create data
c) Create definetype
d) Create type
View Answer
Answer: d
Explanation: The create type clause can be used to define new
types.Syntax : create type Dollars as numeric(12,2) final; .
6. Values of one type can be converted to another domain using which of
the following?
a) Cast
b) Drop type
c) Alter type
d) Convert
View Answer
Answer: a
Explanation: Example of cast :cast (department.budget to numeric(12,2)).
SQL provides drop type and alter type clauses to drop or modify types that
have been created earlier.

7.

CREATE DOMAIN YearlySalary NUMERIC(8,2)


CONSTRAINT salary VALUE test __________;
In order to ensure that an instructor’s salary domain allows only values
greater than a specified value use:
a) Value>=30000.00
b) Not null;
c) Check(value >= 29000.00);
d) Check(value)
View Answer
Answer: c
Explanation: Check(value ‘condition’) is the syntax.

8. Which of the following closely resembles Create view?


a) Create table . . .like
b) Create table . . . as
c) With data
d) Create view as
View Answer
Answer: b
Explanation: The ‘create table . . . as’ statement closely resembles the
create view statement and both are defined by using queries. The main
difference is that the contents of the table are set when the table is created,
whereas the contents of a view always reflect the current query result.
9. In contemporary databases, the top level of the hierarchy consists of
______ each of which can contain _____
a) Catalogs, schemas
b) Schemas, catalogs
c) Environment, schemas
d) Schemas, Environment
View Answer
Answer: a
Explanation: None.

10. Which of the following statements creates a new table temp instructor
that has the same schema as an instructor.
a) create table temp_instructor;
b) Create table temp_instructor like instructor;
c) Create Table as temp_instructor;
d) Create table like temp_instructor;
View Answer
Answer: b
Explanation: None.

Database Questions and Answers – Authorizations


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Authorizations”.

1. The database administrator who authorizes all the new users, modifies
the database and takes grants privilege is
a) Super user
b) Administrator
c) Operator of operating system
d) All of the mentioned
View Answer
Answer: d
Explanation: The authorizations provided by the administrator to the user is
a privilege.

2. Which of the following is a basic form of grant statement?


a)

GRANT 'privilege list'


ON 'relation name or view name'
TO 'user/role list';
b)

advertisement

ADVERTISEMENT

ADVERTISEMENT
GRANT 'privilege list'
ON 'user/role list'
TO 'relation name or view name';
c)

Note: Join free Sanfoundry classes at Telegram or Youtube


GRANT 'privilege list'
TO 'user/role list'
d)

GRANT 'privilege list'


ON 'relation name or view name'
ON 'user/role list';
View Answer

Answer: a
Explanation: The privilege list allows the granting of several privileges in
one command .

3. Which of the following is used to provide privilege to only a particular


attribute?
a) Grant select on employee to Amit
b) Grant update(budget) on department to Raj
c) Grant update(budget,salary,Rate) on department to Raj
d) Grant delete to Amit
View Answer
Answer: b
Explanation: This grant statement gives user Raj update authorization on
the budget attribute of the department relation.

4. Which of the following statement is used to remove the privilege from the
user Amir?
a) Remove update on department from Amir
b) Revoke update on employee from Amir
c) Delete select on department from Raj
d) Grant update on employee from Amir
View Answer
Answer: b
Explanation: revoke on from ;

5. Which of the following is used to provide delete authorization to


instructor?
a)

CREATE ROLE instructor ;


GRANT DELETE TO instructor;
b)

CREATE ROLE instructor;


GRANT SELECT ON takes
TO instructor;
c)

CREATE ROLE instructor;


GRANT DELETE ON takes
TO instructor;
d) All of the mentioned
View Answer
Answer: c
Explanation: The role is first created and the authorization is given on
relation takes to the role.

6. Which of the following is true regarding views?


a) The user who creates a view cannot be given update authorization on a
view without having update authorization on the relations used to define the
view
b) The user who creates a view cannot be given update authorization on a
view without having update authorization on the relations used to define the
view
c) If a user creates a view on which no authorization can be granted, the
system will allow the view creation request
d) A user who creates a view receives all privileges on that view
View Answer
Answer: c
Explanation: A user who creates a view does not necessarily receive all
privileges on that view.

7. If we wish to grant a privilege and to allow the recipient to pass the


privilege on to other users, we append the __________ clause to the
appropriate grant command.
a) With grant
b) Grant user
c) Grant pass privelege
d) With grant option
View Answer
Answer: d
Explanation: None.

8. In authorization graph, if DBA provides authorization to u1 which inturn


gives to u2 which of the following is correct?
a) If DBA revokes authorization from u1 then u2 authorization is also
revoked
b) If u1 revokes authorization from u2 then u2 authorization is revoked
c) If DBA & u1 revokes authorization from u1 then u2 authorization is also
revoked
d) If u2 revokes authorization then u1 authorization is revoked
View Answer
Answer: c
Explanation: A user has an authorization if and only if there is a path from
the root of the authorization graph down to the node representing the user.

9. Which of the following is used to avoid cascading of authorizations from


the user?
a) Granted by current role
b) Revoke select on department from Amit, Satoshi restrict;
c) Revoke grant option for select on department from Amit;
d) Revoke select on department from Amit, Satoshi cascade;
View Answer
Answer: b
Explanation: The revoke statement may specify restrict in order to prevent
cascading revocation. The keyword cascade can be used instead of restrict
to indicate that revocation should cascade.

10. The granting and revoking of roles by the user may cause some
confusions when that user role is revoked. To overcome the above
situation
a) The privilege must be granted only by roles
b) The privilege is granted by roles and users
c) The user role cannot be removed once given
d) By restricting the user access to the roles
View Answer
Answer: a
Explanation: The current role associated with a session can be set by
executing set role name. The specified role must have been granted to the
user, else the set role statement fails.

Database Questions and Answers – Access SQL From a


Programming Language
This set of Database Multiple Choice Questions & Answers focuses on
“Access SQL From a Programming Language”.

1. Which of the following is used to access the database server at the time
of executing the program and get the data from the server accordingly?
a) Embedded SQL
b) Dynamic SQL
c) SQL declarations
d) SQL data analysis
View Answer
Answer: b

2. Which of the following header must be included in java program to


establish database connectivity using JDBC ?
a) Import java.sql.*;
b) Import java.sql.odbc.jdbc.*;
c) Import java.jdbc.*;
d) Import java.sql.jdbc.*;
View Answer
Answer: a
Explanation: The Java program must import java.sql.*, which contains the
interface definitions for the functionality provided by JDBC.

3. DriverManager.getConnection(_______ , ______ , ______)


What are the two parameters that are included?
a) URL or machine name where server runs, Password, User ID
b) URL or machine name where server runs, User ID, Password
c) User ID, Password, URL or machine name where server runs
d) Password, URL or machine name where server runs, User ID
View Answer
Answer: b
Explanation: The database must be opened first in order to perform any
operations for which this get connection method is used.

4. Which of the following invokes functions in sql?


a) Prepared Statements
b) Connection statement
c) Callable statements
d) All of the mentioned
View Answer
Answer: c
Explanation: JDBC provides a Callable Statement interface that allows
invocation of SQL stored procedures and functions.

5. Which of the following function is used to find the column count of the
particular resultset?
a) getMetaData()
b) Metadata()
c) getColumn()
d) get Count()
View Answer
Answer: a
6. Which of the following is a following statement is a prepared statements?
a) Insert into department values(?,?,?)
b) Insert into department values(x,x,x)
c) SQLSetConnectOption(conn, SQL AUTOCOMMIT, 0)
d) SQLTransact(conn, SQL ROLLBACK)
View Answer

Answer: a
Explanation:? is used as a placeholder whose value can be provided later.

7. Which of the following is used as the embedded SQL in COBOL?


a) EXEC SQL <embedded SQL statement >;
b) EXEC SQL <embedded SQL statement > END-EXEC
c) EXEC SQL <embedded SQL statement >
d) EXEC SQL <embedded SQL statement > END EXEC;
View Answer
Answer: b
Explanation: EXEC SQL <embedded SQL statement >; is normally in C.

8. Which of the following is used to distinguish the variables in SQL from


the host language variables?
a) .
b) –
c) :
d) ,
View Answer
Answer: c
Explanation:
EXEC SQL
DECLARE c cursor FOR
SELECT ID, name
FROM student
WHERE tot cred > :credit amount;
.

9. The update statement can be executed in host language using


a) EXEC SQL update c;
b) EXEC SQL update c into :si, :sn;
c)

EXEC SQL
UPDATE instructor
SET salary = salary + 100
WHERE CURRENT OF c;
d) EXEC SQL update END-SQL
View Answer
Answer: c
Explanation: The SQL can be terminated by ; to terminate the sentence.

10. Which of the following is used to access large objects from a


database ?
a) setBlob()
b) getBlob()
c) getClob()
d) all of the mentioned
View Answer
Answer: d

Database Questions and Answers – Triggers

1. A __________ is a special kind of a store procedure that executes in


response to certain action on the table like insertion, deletion or updation of
data.
a) Procedures
b) Triggers
c) Functions
d) None of the mentioned
View Answer
Answer: b
Explanation: Triggers are automatically generated when a particular
operation takes place.

2. Triggers are supported in


a) Delete
b) Update
c) Views
d) All of the mentioned
View Answer
Answer: c
Explanation: The triggers run after an insert, update or delete on a table.
They are not supported for views.

3. The CREATE TRIGGER statement is used to create the trigger. THE


_____ clause specifies the table name on which the trigger is to be
attached. The ______ specifies that this is an AFTER INSERT trigger.
a) for insert, on
b) On, for insert
c) For, insert
d) None of the mentioned
View Answer
Answer: b
Explanation: The triggers run after an insert, update or delete on a table.
They are not supported for views.

4. What are the after triggers?


a) Triggers generated after a particular operation
b) These triggers run after an insert, update or delete on a table
c) These triggers run after an insert, views, update or delete on a table
d) All of the mentioned
View Answer
Answer: b
Explanation: AFTER TRIGGERS can be classified further into three types
as: AFTER INSERT Trigger, AFTER UPDATE Trigger, AFTER DELETE
Trigger.

5. The variables in the triggers are declared using


a) –
b) @
c) /
d) /@
View Answer
Answer: b
Explanation: Example : declare @empid int; where empid is the variable.
6. The default extension for an Oracle SQL*Plus file is:
a) .txt
b) .pls
c) .ora
d) .sql
View Answer
Answer: d

7. Which of the following is NOT an Oracle-supported trigger?


a) BEFORE
b) DURING
c) AFTER
d) INSTEAD OF
View Answer
Answer: b
Explanation: Example: During trigger is not possible in any database.

8. What are the different in triggers?


a) Define, Create
b) Drop, Comment
c) Insert, Update, Delete
d) All of the mentioned
View Answer
Answer: c
Explanation: Triggers are not possible for create, drop.

9. Triggers ________ enabled or disabled


a) Can be
b) Cannot be
c) Ought to be
d) Always
View Answer
Answer: a
Explanation: Triggers can be manipulated.

10. Which prefixes are available to Oracle triggers?


a) : new only
b) : old only
c) Both :new and : old
d) Neither :new nor : old
View Answer
Answer: c

Database Questions and Answers – Recursive Queries and


Aggregation Features
This set of Database Quiz focuses on “Recursive Queries and Aggregation
Features”.

1. Any recursive view must be defined as the union of two subqueries: a


_______ query that is nonrecursive and a __________ query.
a) Base, recursive
b) Recursive, Base
c) Base, Redundant
d) View, Base
View Answer
Answer: a
Explanation: First compute the base query and add all the resultant tuples
to the recursively defined view relation.

2. Ranking of queries is done by which of the following?


a) Group by
b) Order by
c) Having
d) Both Group by and Order by
View Answer
Answer: b
Explanation: Order by clause arranges the values in ascending or
descending order where a default is ascending order.

3. In rank() function if one value is shared by two tuples then


a) The rank order continues as counting numbers
b) The rank order continues by leaving one rank in the middle
c) The user specifies the order
d) The order does not change
View Answer
Answer: b
Explanation: Example. rank() over (order by (GPA) desc).
4. The __________ function that does not create gaps in the ordering.
a) Intense_rank()
b) Continue_rank()
c) Default_rank()
d) Dense_rank()
View Answer
Answer: d
Explanation: For dense_rank() the tuples with the second highest value all
get rank 2, and tuples with the third highest value get rank 3, and so on.

5.

Note: Join free Sanfoundry classes at Telegram or Youtube


SELECT ID, GPA
FROM student grades
ORDER BY GPA
____________;
Inorder to give only 10 rank on the whole we should use
a) Limit 10
b) Upto 10
c) Only 10
d) Max 10
View Answer
Answer: a
Explanation: However, the limit clause does not support partitioning, so we
cannot get the top n within each partition without performing ranking;
further, if more than one student gets the same GPA, it is possible that one
is included in the top 10, while another is excluded.

6. If there are n tuples in the partition and the rank of the tuple is r, then its
________ is defined as (r −1)/(n−1).
a) Ntil()
b) Cum_rank
c) Percent_rank
d) rank()
View Answer
Answer: c
Explanation: Percent rank of a tuple gives the rank of the tuple as a
fraction.

7. Inorder to simplify the null value confusion in the rank function we can
specify
a) Not Null
b) Nulls last
c) Nulls first
d) Either Nulls last or first
View Answer
Answer: d
Explanation: select ID, rank () over (order by GPA desc nulls last) as s rank
from student grades;.

8. Suppose we are given a view tot credits (year, num credits) giving the
total number of credits taken by students in each year. The query that
computes averages over the 3 preceding tuples in the specified sort order
is
a)

SELECT YEAR, avg(num credits)


OVER (ORDER BY YEAR ROWS 3 preceding)
AS avg total credits
FROM tot credits;
b)

SELECT YEAR, avg(num credits)


OVER (ORDER BY YEAR ROWS 3 unbounded preceding)
AS avg total credits
FROM tot credits;
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: a
Explanation: Suppose that instead of going back a fixed number of tuples,
we want the window to consist of all prior years we use rows unbounded
preceding.
9. The functions which construct histograms and use buckets for ranking is
a) Rank()
b) Newtil()
c) Ntil()
d) None of the mentioned
View Answer
Answer: c
Explanation: For each tuple, ntile(n) then gives the number of the bucket in
which it is placed, with bucket numbers starting with 1.

10. The command ________________ such tables are available only


within the transaction executing the query and are dropped when the
transaction finishes.
a) Create table
b) Create temporary table
c) Create view
d) Create label view
View Answer
Answer: b

Database Questions and Answers – OLAP


This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “OLAP”.

1. OLAP stands for


a) Online analytical processing
b) Online analysis processing
c) Online transaction processing
d) Online aggregate processing
View Answer
Answer: a
Explanation: OLAP is the manipulation of information to support decision
making.

2. Data that can be modeled as dimension attributes and measure


attributes are called _______ data.
a) Multidimensional
b) Singledimensional
c) Measured
d) Dimensional
View Answer
Answer: a
Explanation: Given a relation used for data analysis, we can identify some
of its attributes as measure attributes, since they measure some value, and
can be aggregated upon.Dimension attribute define the dimensions on
which measure attributes, and summaries of measure attributes, are
viewed.

3. The generalization of cross-tab which is represented visually is


____________ which is also called as data cube.
a) Two dimensional cube
b) Multidimensional cube
c) N-dimensional cube
d) Cuboid
View Answer
Answer: a
Explanation: Each cell in the cube is identified for the values for the three
dimensional attributes.

4. The process of viewing the cross-tab (Single dimensional) with a fixed


value of one attribute is
a) Slicing
b) Dicing
c) Pivoting
d) Both Slicing and Dicing
View Answer
Answer: a
Explanation: The slice operation selects one particular dimension from a
given cube and provides a new sub-cube. Dice selects two or more
dimensions from a given cube and provides a new sub-cube.

5. The operation of moving from finer-granularity data to a coarser


granularity (by means of aggregation) is called a ________
a) Rollup
b) Drill down
c) Dicing
d) Pivoting
View Answer
Answer: a
Explanation: The opposite operation—that of moving fromcoarser-
granularity data to finer-granularity data—is called a drill down.

6. In SQL the cross-tabs are created using


a) Slice
b) Dice
c) Pivot
d) All of the mentioned
View Answer
Answer: a
Explanation: Pivot (sum(quantity) for color in (’dark’,’pastel’,’white’)).

7.

{ (item name, color, clothes size), (item name, color),


(item name, clothes size), (color, clothes size), (item
name), (color), (clothes size), () }
This can be achieved by using which of the following ?
a) group by rollup
b) group by cubic
c) group by
d) none of the mentioned
View Answer
Answer: d
Explanation: ‘Group by cube’ is used .

8. What do data warehouses support?


a) OLAP
b) OLTP
c) OLAP and OLTP
d) Operational databases
View Answer
Answer: a
Explanation: None.

9.

SELECT item name, color, clothes SIZE, SUM(quantity)


FROM sales
GROUP BY rollup(item name, color, clothes SIZE);
How many grouping is possible in this rollup?
a) 8
b) 4
c) 2
d) 1
View Answer
Answer: b
Explanation: { (item name, color, clothes size), (item name, color), (item
name), () }.

10. Which one of the following is the right syntax for DECODE?
a) DECODE (search, expression, result [, search, result]… [, default])
b) DECODE (expression, result [, search, result]… [, default], search)
c) DECODE (search, result [, search, result]… [, default], expression)
d) DECODE (expression, search, result [, search, result]… [, default])
View Answer
Answer: d
Explanation: None.

Database Questions and Answers – Relational Algebra

1. Relational Algebra is a __________ query language that takes two


relations as input and produces another relation as an output of the query.
a) Relational
b) Structural
c) Procedural
d) Fundamental
View Answer
Answer: c
Explanation: This language has fundamental and other operations which
are used on relations.

2. Which of the following is a fundamental operation in relational algebra?


a) Set intersection
b) Natural join
c) Assignment
d) None of the mentioned
View Answer
Answer: d
Explanation: The fundamental operations are select, project, union, set
difference, Cartesian product, and rename.

3. Which of the following is used to denote the selection operation in


relational algebra?
a) Pi (Greek)
b) Sigma (Greek)
c) Lambda (Greek)
d) Omega (Greek)
View Answer
Answer: b
Explanation: The select operation selects tuples that satisfy a given
predicate.

advertisement

4. For select operation the ________ appear in the subscript and the
___________ argument appears in the paranthesis after the sigma.
a) Predicates, relation
b) Relation, Predicates
c) Operation, Predicates
d) Relation, Operation
View Answer
Answer: a
Explanation: None.

5. The ___________ operation, denoted by −, allows us to find tuples that


are in one relation but are not in another.
a) Union
b) Set-difference
c) Difference
d) Intersection
View Answer
Answer: b
Explanation: The expression r − s produces a relation containing those
tuples in r but not in s.
6. Which is a unary operation:
a) Selection operation
b) Primitive operation
c) Projection operation
d) Generalized selection
View Answer
Answer: d
Explanation: Generalization Selection takes only one argument for
operation.

7. Which is a join condition contains an equality operator:


a) Equijoins
b) Cartesian
c) Natural
d) Left
View Answer
Answer: a
Explanation: None.

8. In precedence of set operators, the expression is evaluated from


a) Left to left
b) Left to right
c) Right to left
d) From user specification
View Answer
Answer: b
Explanation: The expression is evaluated from left to right according to the
precedence.

9. Which of the following is not outer join?


a) Left outer join
b) Right outer join
c) Full outer join
d) All of the mentioned
View Answer
Answer: d
Explanation: The FULL OUTER JOIN keyword combines the result of both
LEFT and RIGHT joins.
10. The assignment operator is denoted by
a) ->
b) <-
c) =
d) ==
View Answer
Answer: b
Explanation: The result of the expression to the right of the ← is assigned
to the relation variable on the left of the ←.

Database Questions and Answers – Tuple Relational


Calculus and Domain Relational Calculus

1. Find the ID, name, dept name, salary for instructors whose salary is

a) {t | t ε instructor ∧ t[salary] > 80000}


greater than $80,000 .

b) Э t ∈ r (Q(t))
c) {t | Э s ε instructor (t[ID] = s[ID]∧ s[salary] > 80000)}
d) None of the mentioned
View Answer
Answer: a
Explanation: This expression is in tuple relational format.

2. A query in the tuple relational calculus is expressed as:


a) {t | P() | t}
b) {P(t) | t }
c) {t | P(t)}
d) All of the mentioned
View Answer
Answer: c
Explanation: The tuple relational calculus, is a nonprocedural query
language. It describes the desired information without giving a specific
procedure for obtaining that information.

3.

∧ Э u ε department (u[dept name] = s[dept name]


{t | Э s ε instructor (t[name] = s[name]

∧ u[building] = “Watson”))}
Which of the following best describes the query?
a) Finds the names of all instructors whose department is in the Watson
building
b) Finds the names of all department is in the Watson building
c) Finds the name of the dapartment whose instructor and building is
Watson
d) Returns the building name of all the departments
View Answer
Answer: a
Explanation: This query has two “there exists” clauses in our tuple-
relational-calculus expression, connected by and (∧).

Note: Join free Sanfoundry classes at Telegram or Youtube

4. Which of the following symbol is used in the place of except?


a) ^
b) V
c) ¬
d) ~
View Answer
Answer: c
Explanation: The query ¬P negates the value of P.

5. “Find all students who have taken all courses offered in the Biology
department.” The expressions that matches this sentence is :

b) ∀ t ε r (Q(t))
a) Э t ε r (Q(t))

c) ¬ t ε r (Q(t))
d) ~ t ε r (Q(t))
View Answer

Explanation: ∀ is used denote “for all” in SQL.


Answer: b

6. Which of the following is the comparison operator in tuple relational

a) ⇒
calculus

b) =
c) ε
d) All of the mentioned
View Answer
Answer: b
Explanation: The comparison operators are (<, ≤, =, =, >, ≥).

7. An expression in the domain relational calculus is of the form


a) {P(x1, x2, . . . , xn) | < x1, x2, . . . , xn > }
b) {x1, x2, . . . , xn | < x1, x2, . . . , xn > }
c) { x1, x2, . . . , xn | x1, x2, . . . , xn}
d) {< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)}
View Answer
Answer: d
Explanation: Here x1, x2, . . . , xn represent domain variables. P represents
a formula composed of atoms, as was the case in the tuple relational
calculus.

8. Find the names of all instructors in the Physics department together with
the course id of all courses they teach:
a)

{< c > | Э s (< c, a, s, y, b, r, t >ε section

∧s = “Fall” ∧ y = “2009”

∨Эu (< c, a, s, y, b, r, t >ε section

∧s = “Spring” ∧ y = “2010”

b)

{< n, c > | Э i, a (< i, c, a, s, y > ε teaches

∧ Э d, s (< i, n, d, s > ε instructor ∧ d = “Physics”))}

c)

{< n > | Э i, d, s (< i, n, d, s > ε instructor ∧ s > 80000)}


d)

{< i, n, d, s > | < i, n, d, s > ε instructor ∧ s > 80000}

View Answer

Answer: b

9. In domain relaional calculus “there exist” can be expressed as


a) (P1(x))
b) (P1(x)) Э x
c) V x (P1(x))
d) Э x (P1(x))
View Answer
Answer: d
Explanation:Э is used to denote “some” values in relational calculus.

10. A set of possible data values is called


a) Attribute
b) Degree
c) Tuple
d) Domain
View Answer
Answer: d

You might also like