Database MCQ Set 1
1. The database administrator who authorizes all the new users, modifies database and takes grants privilege is
a) Super user
b) Administrator
c) Operator of operating system
d) All of the mentioned
Answer
Answer: d [Reason:] The authorizations provided by the administrator to the user is 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) GRANT 'privilege list' ON 'user/role list' TO 'relation name or view name'; c) GRANT 'privilege list' TO 'user/role list' d) GRANT 'privilege list' ON 'relation name or view name' ON 'user/role list';
Answer
Answer: a [Reason:] 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
Answer
Answer: b [Reason:] 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
Answer
Answer: b [Reason:] revoke
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
Answer
Answer: c [Reason:] 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
Answer
Answer: c [Reason:] 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
Answer
Answer: d [Reason:] 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
Answer
Answer: c [Reason:] 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;
Answer
Answer: b [Reason:] 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
Answer
Answer: a [Reason:] The current role associated with a session can be set by executing set role role name. The specified role must have been granted to the user, else the set role statement fails.
Database MCQ Set 2
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
Answer
Answer: c [Reason:] As keyword is used to rename.
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
Answer
Answer: c [Reason:] For any string operations single quoted(‘) must be used to enclose.
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) $
Answer
Answer: a [Reason:] 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
Answer
Answer: b [Reason:] 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
Answer
Answer: d [Reason:] 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
Answer
Answer: c [Reason:] 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;
Answer
Answer: a [Reason:] 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
Answer
Answer: b [Reason:] 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
Answer
Answer: c [Reason:] The syntax of trim is Trim(s); where s-string .
10. _____ operator is used for appending two strings.
a) &
b) %
c) ||
d) _
Answer
Answer: c [Reason:] || is the concatenation operator.
Database MCQ Set 3
1. Bitmap indices are a specialized type of index designed for easy querying on _____
a) Bit values
b) Binary digits
c) Multiple keys
d) Single keys
Answer
Answer: c [Reason:] Each bitmap index is built on a single key.
2. A _______ on the attribute A of relation r consists of one bitmap for each value that A can take.
a) Bitmap index
b) Bitmap
c) Index
d) Array
Answer
Answer: a [Reason:] A bitmap is simply an array of bits.
3.
SELECT * FROM r WHERE gender = ’f’ AND income level = ’L2’;
In this selection, we fetch the bitmaps for gender value f and the bitmap for income level value L2, and perform an ________ of the two bitmaps.
a) Union
b) Addition
c) Combination
d) Intersection
Answer
Answer: d [Reason:] We compute a new bitmap where bit i has value 1 if the ith bit of the two bitmaps are both 1, and has a value 0 otherwise.
4. To identify the deleted records we use the ________
a) Existence bitmap
b) Current bitmap
c) Final bitmap
d) Deleted bitmap
Answer
Answer: a [Reason:] The bitmaps which are deleted are denoted by 0.
5. Bitmaps can be used as a compressed storage mechanism at the leaf nodes of ________ for those values that occur very frequently.
a) B-trees
b) B+-trees
c) Bit trees
d) Both B-trees and B+-trees
Answer
Answer: b [Reason:] Bitmaps are combined and stored in a B+ tree.
6. Bitmaps can be combined with regular B+-tree indices for relations where a few attribute values are extremely common, and other values also occur, but much less frequently.
a) Bitmap, B-tree
b) Bitmap, B+tree
c) B-tree, Bitmap
d) B+tree, Bitmap
Answer
Answer: b [Reason:] Bitmaps are combined and stored in a B+ tree.
7. In a B+-tree index ______ for each value we would normally maintain a list of all records with that value for the indexed attribute.
a) Leaf
b) Node
c) Root
d) Link
Answer
Answer: a [Reason:] Bitmaps are combined and stored in a B+ tree.
8. A tablespace is further broken down into ________
a) Tablespace
b) Segments
c) Extents
d) Blocks
Answer
Answer: b [Reason:] Segment names are used in create table and create index commands to place tables or indexes on specific database devices.
9. In ordered indices the file containing the records is sequentially ordered, a _____ is an index whose search key also defines the sequential order of the file.
a) Clustered index
b) Structured index
c) Unstructured index
d) Nonclustered index
Answer
Answer: a [Reason:] Clustering index are also called primary indices; the term primary index may appear to denote an index on a primary key, but such indices can in fact be built on any search key.
10. Indices whose search key specifies an order different from the sequential order of the file are called _____ indices.
a) Nonclustered
b) Secondary
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] Nonclustering index are also called secondary indices.
Database MCQ Set 4
1. In order to reduce the overhead in retrieving the records from the storage space we use
a) Logs
b) Log buffer
c) Medieval space
d) Lower records
Answer
Answer: b [Reason:] The output to stable storage is in units of blocks.
2. The order of log records in the stable storage ______ as the order in which they were written to the log buffer.
a) Must be exactly the same
b) Can be different
c) Is opposite
d) Can be partially same
Answer
Answer: a [Reason:] As a result of log buffering, a log record may reside in only main memory (volatile storage) for a considerable time before it is output to stable storage.
3. Before a block of data in main memory can be output to the database, all log records pertaining to data in that block must have been output to stable storage. This is
a) Read-write logging
b) Read-ahead logging
c) Write-ahead logging
d) None of the mentioned
Answer
Answer: c [Reason:] The WAL rule requires only that the undo information in the log has been output to stable storage, and it permits the redo information to be written later.
4. Writing the buffered log to ____ is sometimes referred to as a log force.
a) Memory
b) Backup
c) Redo memory
d) Disk
Answer
Answer: d [Reason:] If there are insufficient log records to fill the block, all log records in main memory are combined into a partially full block and are output to stable storage.
5. The ___ policy, allows a transaction to commit even if it has modified some blocks that have not yet been written back to disk.
a) Force
b) No-force
c) Steal
d) No-steal
Answer
Answer: b [Reason:] No-force policy allows faster commit of transactions.
6. ________ policy allows multiple updates to accumulate on a block before it is output to stable storage, which can reduce the number of output operations greatly for frequently updated blocks.
a) Force
b) No-force
c) Steal
d) No-steal
Answer
Answer: b [Reason:] No-force policy allows faster commit of transactions.
7. The _____ policy, allows the system to write modified blocks to disk even if the transactions thatmade those modifications have not all committed.
a) Force
b) No-force
c) Steal
d) No-steal
Answer
Answer: c [Reason:] The no-steal policy does not work with transactions that perform a large number of updates.
8. Locks on buffer blocks are unrelated to locks used for concurrency-control of transactions, and releasing them in a non-two-phase manner does not have any implications on transaction serializability. This is
a) Latches
b) Swap Space
c) Dirty Block
d) None of the mentioned
Answer
Answer: a [Reason:] These locks, and other similar locks that are held for a short duration.
9. The ______ contains a list of blocks that have been updated in the database buffer.
a) Latches
b) Swap Space
c) Dirty Block
d) None of the mentioned
Answer
Answer: c [Reason:] Dirty blocks are those that have been updated in memory, and the disk version is not up-to-date.
10. The operating system reserves space on disk for storing virtual-memory pages that are not currently in main memory; this space is called
a) Latches
b) Swap Space
c) Dirty Block
d) None of the mentioned
Answer
Answer: b [Reason:] Almost all current-generation operating systems retain complete control of virtual memory.
Database MCQ Set 5
1. _______ express the number of entities to which another entity can be associated via a relationship set.
a) Mapping Cardinality
b) Relational Cardinality
c) Participation Constraints
d) None of the mentioned
Answer
Answer: a [Reason:] Mapping cardinality is also called as cardinality ratio.
2. An entity in A is associated with at most one entity in B, and an entity in B is associated with at most one entity in A.This is called as
a) One-to-many
b) One-to-one
c) Many-to-many
d) Many-to-one
Answer
Answer: b [Reason:] Here one entity in one set is related to one one entity in other set.
3. An entity in A is associated with at most one entity in B. An entity in B, however, can be associated with any number (zero or more) of entities in A.
a) One-to-many
b) One-to-one
c) Many-to-many
d) Many-to-one
Answer
Answer: d [Reason:] Here more than one entity in one set is related to one one entity in other set.
4. 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
d) Prevent users from changing the values stored in the table
Answer
Answer: c [Reason:] The data entered will be in a particular cell (i.e., table column).
5. Establishing limits on allowable property values, and specifying a set of acceptable, predefined options that can be assigned to a property are examples of:
a) Attributes
b) Data integrity constraints
c) Method constraints
d) Referential integrity constraints
Answer
Answer: b [Reason:] Only particular value satsfying the constraints are entered in column .
6. 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) Then entering an order quantity, the user must input a number and not some text (i.e., 12 rather than ‘a dozen’)
Answer
Answer: c [Reason:] None.
7. ______ is a special type of integrity constraint that relates two relations & maintains consistency across the relations.
a) Entity Integrity Constraints
b) Referential Integrity Constraints
c) Domain Integrity Constraints
d) Domain Constraints
Answer
Answer: b [Reason:] None.
8. Which one of the following uniquely identifies the elements in the relation?
a) Secondary Key
b) Primary key
c) Foreign key
d) Composite key
Answer
Answer: b [Reason:] Primary key checks for not null and uniqueness constraint .
9. Drop Table cannot be used to drop a table referenced by a ___ constraint.
a) Local Key
b) Primary Key
c) Composite Key
d) Foreign Key
Answer
Answer: d [Reason:] Foreign key is used when primary key of one relation is used in another relation .
10. ______ is preferred method for enforcing data integrity
a) Constraints
b) Stored Procedure
c) Triggers
d) Cursors
Answer
Answer: a [Reason:] Constraints are specified to restrict entries in the relation.