Database MCQ Set 1
1. Which of the following information is captured by database profiler ?
a) Read operations
b) Write operations
c) Cursor Operations
d) All of the mentioned
Answer
Answer: d [Reason:] The database profiler captures data information about read and write operations, cursor operations, and database commands.
2. Point out the correct statement :
a) A limit() value of 0 (i.e. .limit(0)) is equivalent to setting no limit
b) The behavior of limit() is undefined for values less than -231 and greater than 231
c) You can use the ulimit command at the system prompt to check system limits
d) All of the mentioned
Answer
Answer: d [Reason:] Use limit() to maximize performance and prevent MongoDB from returning more results than required for processing.
3. Which of the following collection is capped ?
a) system.index
b) system.replica
c) system.profile
d) all of the mentioned
Answer
Answer: c [Reason:] The database profiler writes data in the system.profile collection, which is a capped collection.
4. The _____ provides information for various lock types and lock modes held during the operation.
a) admin.system.authlocks
b) system.profile.locks
c) admin.system.locks
d) all of the mentioned
Answer
Answer: b [Reason:] MongoDB uses reader-writer locks that allow concurrent readers shared access to a resource, such as a database or collection, but give exclusive access to a single write operation.
5. Point out the wrong statement :
a) Beginning with version 3.0, MongoDB ships with the WiredTiger storage engine
b) Some global operations, typically short lived operations involving multiple databases, still require a global “instance-wide” lock
c) The MMAPv1 storage engine uses collection-level locking
d) None of the mentioned
Answer
Answer: d [Reason:] MongoDB operations can also yield locks between individual document modifications in write operations that affect multiple documents like update() with the multi parameter.
6. Which of the following keyword represents lock on collection ?
a) Database
b) Collection
c) Metadata
d) All of the mentioned
Answer
Answer: b [Reason:] Database represents database lock.
7. How many types of locking modes exist in MongoDB ?
a) 1
b) 2
c) 3
d) More than 3
Answer
Answer: d [Reason:] There are four possible locking modes for the lock types.
8. Which of the following represents Shared lock ?
a) R
b) w
c) r
d) W
Answer
Answer: a [Reason:] W represents Exclusive (X) lock.
9. Which of the following represents number of times the operation acquired the lock in the specified mode ?
a) system.profile.locks.acquireCount
b) system.profile.locks.acquireWaitCount
c) system.profile.locks.Count
d) none of the mentioned
Answer
Answer: a [Reason:]
system.profile.locks.acquireWaitCount is number of times the operation had to wait for the acquireCount lock acquisitions because the locks were held in a conflicting mode. acquireWaitCount is less than or equal to acquireCount.
10.____ can be used to limit the size of the result document for a query operation.
a) limit()
b) aggregate()
c) skip()
d) none of the mentioned
Answer
Answer: a [Reason:] limit() is analogous to the LIMIT statement in a SQL database.
Database MCQ Set 2
1. Replica set configuration requires that the _______ have a value that is consistent among all members of the set.
a) replSetName
b) instance
c) MMS
d) all of the mentioned
Answer
Answer: a [Reason:] Use descriptive names for sets. Once configured, use the mongo shell to add hosts to the replica set.
2. Point out the correct statement :
a) Replica set configuration is straightforward
b) Keyfile must be less than one kilobyte in size
c) Keyfile may only contain characters in the base64 set and the file must not have group or “world” permissions on UNIX systems
d) All of the mentioned
Answer
Answer: d [Reason:] To enable authentication for the replica set, add the keyFile option.
3. Setting _______ enables authentication and specifies a key file for the replica set member use to when authenticating to each other.
a) mongostat
b) mongod
c) keyFile
d) all of the mentioned
Answer
Answer: c [Reason:] The content of the key file is arbitrary, but must be the same on all members of the replica set and mongos instances that connect to the set.
4. _______ is /srv/mongodb, which specifies where MongoDB will store its data files
a) dbPath
b) dbPathSts
c) db.Op
d) none of the mentioned
Answer
Answer: a [Reason:] The user account that mongod runs under will need read and write access to this directory.
5. Point out the correct statement :
a) Config servers are not replica sets
b) Sharding requires a number of mongod instances with different configurations
c) The config servers store the cluster’s metadata, while the cluster distributes data among one or more shard servers
d) None of the mentioned
Answer
Answer: d [Reason:] The command line and configuration file interfaces provide MongoDB administrators with a large number of options and settings for controlling the operation of the database system.
6. _____ bit builds of mongod enable journaling by default.
a) 8
b) 16
c) 32
d) 64
Answer
Answer: d [Reason:] Journaling ensures single instance write-durability.
7. Which of the following provide acceptable performance levels for multiple mongod instances?
a) GridFS
b) SST
c) MMS
d) SSD
Answer
Answer: d [Reason:] Additionally, you may find that multiple databases with small working sets may function acceptably on a single system.
8. What is the size of Chunk by default ?
a) 64 MB
b) 64 GB
c) 64 KB
d) 32 MB
Answer
Answer: a [Reason:] Default chunk size provides the ideal balance between the most even distribution of data, for which smaller chunk sizes are best, and minimizing chunk migration, for which larger chunk sizes are optimal.
9. Which of the following sets the database profiler level ?
a) systemLog.verbosity
b) operationProfiling.mode
c) operationProfiling.slowOpThresholdMs
d) none of the mentioned
Answer
Answer: b [Reason:] The profiler is not active by default because of the possible impact on the profiler itself on performance.
10. Which of the following document configures the threshold which determines whether a query is “slow” for the purpose of the logging system ?
a) systemLog.verbosity
b) operationProfiling.mode
c) operationProfiling.slowOpThresholdMs
d) none of the mentioned
Answer
Answer: c [Reason:] systemLog.verbosity controls the amount of logging output that mongod write to the log.
Database MCQ Set 3
1. MySQL uses security based on ACL which stands for ________
a) Access Control Language
b) Access Control Lists
c) Automatic Control Lists
d) Automatic Control Language
Answer
Answer: b [Reason:] MySQL uses security based on Access Control Lists (ACLs) for all connections, queries and other operations that users can attempt to perform. There is support for SSL encrypted connections.
2. The mysql client writes a record of executed statements to a history file on Unix.
a) True
b) False
Answer
Answer: a [Reason:] On Unix the mysql client writes a record of the executed statements to a history file. By default this file is named as ‘.mysql_history’. It is created in the home directory.
3. A password applies globally to an account.
a) True
b) False
Answer
Answer: a [Reason:] In the MySQL privilege system, a password applies globally to an account. A password cannot be explicitly associated with a specific object such as a database, table, or routine.
4. The context in which the privilege ‘CREATE TABLESPACE’ applies is ________
a) Server administration
b) Tables
c) Stored routines
d) Views
Answer
Answer: a [Reason:] The column name associated with the privilege ‘CREATE TABLESPACE’ is ‘Create_tablespace_priv’. The context in which this privilege is being used is the server administration.
5. The number of languages that have interfaces to bind to the C API of MySQL among these is ________
Perl, PHP, Python
a) 0
b) 1
c) 2
d) 3
Answer
Answer: d [Reason:] The client library provides the means through which the MySQL bindings for other languages can be built on top of the C API. This type of interface exists for Perl, PHP, Python and others.
6. The language that is the core for APIs and communication in MySQL is ________
a) C
b) C++
c) Python
d) Ruby
Answer
Answer: a [Reason:] In order to provide application development, MySQL provides a client library written in the C programming language. It enables the access of MySQL databases from a C program.
7. The most general purpose language is ________
a) C
b) Perl
c) Python
d) PHP
Answer
Answer: a [Reason:] C is a general purpose language, so in principle it can be used for anything. C tends to be used more often for standalone programs rather than for Web programming in practice.
8. The language in which image processing is least simple is ________
a) PHP
b) Perl
c) Python
d) C
Answer
Answer: d [Reason:] It is not as easy to perform text processing and memory management in C than it is in languages like Perl and PHP. These capabilities tend to be heavily used in the web applications.
9. The option necessary to compile a C program havin math functions is ________
a) -lm
b) -ln
c) -lp
d) -lq
Answer
Answer: a [Reason:] To compile a program written in the C language, it is compiled by issuing the option ‘-lm’. The examples of some math functions found in ‘math.h’ are floor(), sqrt(), pow(), log().
10. What is the option for specifying the executable name while compiling with gcc?
a) -e
b) -o
c) -a
d) -b
Answer
Answer: b [Reason:] When a C program is compiled with gcc, the option -o is issued in order to specify the name of the executable that is created after compilation. The default name given is ‘a.out’.
Database MCQ Set 4
1. Accessing data from which of these is faster?
memory, disk
a) memory
b) disk
c) same speed
d) machine dependent
Answer
Answer: a [Reason:] In MySQL, the administrators have more privileges since they have more control of the MySQL server or the machine on which it runs. Accessing data in memory is faster than from disk.
2. Which system variable controls the size of the table cache?
a) table_cache
b) cache_table
c) open_cache
d) cache_open
Answer
Answer: a [Reason:] In MySQL, when the server opens table files it keeps them open to minimize the number of file-opening operations. It maintains information about open files in the table cache.
3. Which status indicator assesses how effective the table cache is?
a) Open_tables
b) Opened_tables
c) Close_tables
d) Closed_tables
Answer
Answer: b [Reason:] When the server accesses various tables, the table cache fills up. The server closes the tables that have not been used recently in order to make room for opening the new tables.
4. In MySQL, the default size of the key buffer in MB is _____
a) 4
b) 8
c) 16
d) 32
Answer
Answer: b [Reason:] The larger values allow MySQL to hold more index blocks in memory at once. This increases the chances of finding key values in memory without having to read a new block from disk.
5. The system variable to maintain InnoDB log buffer size is _____
a) innodb_log_buffer_size
b) innodb_buffer_log_size
c) buffer_log_innodb_size
d) log_buffer_innodb_size
Answer
Answer: a [Reason:] The InnoDB storage engine has its own cache used for buffering the data and index values. It maintains a log buffer. The size for this is controlled by innodb_log_buffer_size.
6. All queries can be cached.
a) True
b) False
Answer
Answer: b [Reason:] A query is not cached if the query returns non deterministic results. For example, a query that uses the NOW() function returns different results over time. Therefore, it cannot be cached.
7. To determine whether query cache is supported by the server the variable is _____
a) have_query_cache
b) have_cache_query
c) query_cache_have
d) cache_query_have
Answer
Answer: a [Reason:] In MySQL, in order to determine whether a server supports the query cache or not, the value of the ‘have_query_cache’ system variable is checked. It returns ‘YES’ if support is available.
8. Which mode tells not to cache query results?
a) 0
b) 1
c) 2
d) 3
Answer
Answer: a [Reason:] The have_query_cache system variable is used to check whether there is support for query cache. The mode ‘0’ tells not to cache the query results or to retrieve the cached results.
9. Which mode tells cache queries that begin with SELECT SQL_CACHE?
a) 0
b) 1
c) 2
d) 3
Answer
Answer: c [Reason:] The have_query_cache system variable is used to check whether there is support for query cache. The mode ‘2’ tells cache only those queries that begin with SELECT SQL_CACHE.
10. Installing more memory into the machine enables to configure larger values for cache server.
a) True
b) False
Answer
Answer: a [Reason:] Installing more memory into the machine enables to configure larger values for the cache server and buffer sizes. This enables it to keep data in memory for longer duration.
Database MCQ Set 5
1. How many of these languages have interfaces to bind to the C API of MySQL?
Perl, PHP, Python
a) 0
b) 1
c) 2
d) 3
Answer
Answer: d [Reason:] The client library provides the means through which the MySQL bindings for other languages can be built on top of the C API. This type of interface exists for Perl, PHP, Python and others.
2. Which language is the core for APIs and communication in MySQL?
a) C
b) C++
c) Python
d) Ruby
Answer
Answer: a [Reason:] In order to provide application development, MySQL provides a client library written in the C programming language. It enables the access of MySQL databases from a C program.
3. For how many of the following do interfaces exist for implementing direct native client-server protocol?
Java, PHP, Ruby
a) 0
b) 1
c) 2
d) 3
Answer
Answer: d [Reason:] There are interfaces for languages like Java, PHP and Python that implement the native client-server protocol directly instead of using the C library to handle communications.
4. Each language binding defines its own interface for accessing MySQL.
a) True
b) False
Answer
Answer: a [Reason:] Each language binding defines its own interface that dictates all the rules for accessing MySQL. Popular and useful programming languages like C++, Java, Python, PHP and others.
5. The primary programming interface to MySQL is _______
a) C API
b) C++ API
c) Java API
d) Python API
Answer
Answer: a [Reason:] The primary programming interface to MySQL is the C API. It is used to implement some of the standard clients in the MySQL distribution including mysql, mysqladmin and mysqldump.
6. The DBI API for Perl is _______
a) database interface
b) database id
c) database identity
d) database integrity
Answer
Answer: a [Reason:] In MySQL, DBI is implemented as a Perl module. It interfaces with other modules at the DBD (Database Driver) level. Each of it provides access to a specific database engine.
7. For which language is the engine specific interface PDO defined?
a) Python
b) Perl
c) PHP
d) C
Answer
Answer: c [Reason:] Like DBI, PHP includes support for accessing several database engines in addition to MySQL. It has engine specific interfaces, and interfaces that are more engine independent.
8. For which language is the PEAR module used?
a) Python
b) Perl
c) PHP
d) C
Answer
Answer: c [Reason:] The PEAR database module is specified for the language PHP. PHP is a server side scripting language and it provides an appropriate method of embedding programs in the web pages.
9. The JDBI interface is available for _______
a) C
b) C++
c) Python
d) Java
Answer
Answer: d [Reason:] The JDBI interface is available for the programming language Java. Java is one of the most widely popular languages in the world. It is a powerful object oriented programming language.
10. The MySQL APIs are libraries to connect applications to database servers.
a) True
b) False
Answer
Answer: a [Reason:] The MySQL Connectors and APIs are some drivers and libraries. They are used to connect the applications in different programming languages to the database servers of MySQL.