Database MCQ Set 1
1. Which of the syntax is used for creating database snapshot in SQL Server ?
a)
CREATE Snapshot database_snapshot_name ON ( NAME = logical_file_name, FILENAME = 'os_file_name' )
b)
CREATE DATABASESNAPSHOT database_snapshot_name ON ( NAME = logical_file_name, FILENAME = 'os_file_name' )
c)
CREATE DATABASE database_snapshot_name ON ( NAME = logical_file_name, FILENAME = 'os_file_name' )
d) None of the mentioned
Answer
Answer: c [Reason:] Creating a snapshot requires specifying the logical name of every database file of the source database.
2. Point out the correct statement :
a) Snapshots can be used in conjunction with database mirroring for reporting purposes
b) A snapshot is write-only, static view of a database
c) A snapshot is read-only, dynamic view of a database
d) None of the mentioned
Answer
Answer: a [Reason:] You can create a database snapshots on the mirror database and direct client connection requests to the most recent snapshot.
3. Which of the following scenario prefers not to use database snapshots ?
a) Database Snapshots should be seen as high availability option
b) Database Snapshots should not be seen as an alternative to regular backups of your data
c) Snapshots can be created very quickly
d) All of the mentioned
Answer
Answer: b [Reason:] Database snapshots can not protect your databases against disk errors or database corruption.
4. Which of the following code will DROP an existing snapshot before creating new ?
a)
IF NOT EXISTS( SELECT * FROM sys.databases WHERE name = 'DatabaseA_Snapshot' AND source_database_id IS NOT NULL ) BEGIN CREATE DATABASE [DatabaseA_Snapshot] ON (NAME=DatabaseA, FileName='<whatever>') AS SNAPSHOT OF [DatabaseA] END
b)
IF EXISTS( SELECT * FROM sys.databases WHERE name = 'DatabaseA_Snapshot' AND source_database_id IS NOT NULL ) BEGIN CREATE DATABASE [DatabaseA_Snapshot] ON (NAME=DatabaseA, FileName='<whatever>') AS SNAPSHOT OF [DatabaseA] END
c)
IF NOT EXISTS( SELECT * FROM system.databases WHERE name = 'DatabaseA_Snapshot' AND source_database_id IS NOT NULL ) BEGIN CREATE DATABASE [DatabaseA_Snapshot] ON (NAME=DatabaseA, FileName='<whatever>') AS SNAPSHOT OF [DatabaseA] END
d) None of the mentioned
Answer
Answer: a [Reason:] A snapshot database always have an entry in sys.databases.source_database_id.
5. Point out the wrong statement :
a) You cannot used SQL Server Management Studio for creating a database snapshots
b) Snapshots have to be created using T-SQL
c) All recovery models support database snapshot
d) A database can have one and only one snapshot
Answer
Answer: d [Reason:] A database can have multiple snapshots.
6. Which of the following code will throw error ?
a)
CREATE DATABASE AWDB_Snapshot_20080522 ON ( NAME = master, FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataAWDB_Snapshot.ss') AS SNAPSHOT OF master;
b)
CREATE DATABASE AWDB_Snapshot_2008 ON ( NAME = AdventureWorks_Data, FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataAWDB_Snapshot.ss') AS SNAPSHOT OF AdventureWorks;
c)
CREATE DATABASE AWDB_Snapshot_20080 ON ( NAME = AdventureWorks_Data, FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataAWDB_Snapshot.ss') AS SNAPSHOT OF AdventureWorks;
d)
CREATE DATABASE Snapshot_20080522 ON ( NAME = Adventure, FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataAWDB_Snapshot.ss') AS SNAPSHOT OF Adventure;
Answer
Answer: a [Reason:] Snapshot of master database should be created explicitly using SSMS.
7. To revert the database, use the following Transact-SQL statement:
a) RESTORE Snapshot <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
b) RESTORE DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
c) REST DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
d) None of the mentioned
Answer
Answer: b [Reason:] Back up the reverted database, especially if it uses the full (or bulk-logged) recovery model.
8. Which of the following message comes when you try to update or delete the data snapshot?
a) Row Deletion
b) The row was committed
c) Row has been updated
d) Failed to update the database
Answer
Answer: c [Reason:] You will receive a read only message because snapshots have read-only tables.
9. Syntax for creating database snapshot in SQL Server is :
a) DROP DATABASE [snapshottest];
b) DELETE DATABASE [snapshottest];
c) DROP Snapshot [snapshottest];
d) None of the mentioned
Answer
Answer: a [Reason:] We drop the snapshot database like any other database using drop database command.
10.What should be done to check to see if data still exists in Snapshot ?
a) Run Delete on Database Snapshot
b) Run Update on Database Snapshot
c) Run Select on Database Snapshot
d) Run Insert on Database Snapshot
Answer
Answer: c [Reason:] You can run the same SELECT statement on the database snapshot. Here you can see that all of the data which we have deleted in the source database still exists. This is what we will recover using the database snapshot.
Database MCQ Set 2
1. The Client-Side Databases are stored in the
a) The JavaScript code
b) User’s computer
c) Both JavaScript code and User’s computer
d) None of the mentioned
Answer
Answer: b [Reason:] The actual client-side databases are stored on the user’s computer and are directly accessed by JavaScript code in the browser.
2. Which of the following use the Web SQL Database?
a) Chrome
b) Firefox
c) IE
d) All of the mentioned
Answer
Answer: a [Reason:] Chrome, Safari, and Opera implemented the Web SQL Database API, but Firefox and IE have not, and likely never will.
3. Which of the following are objective database and not a relational database?
a) Web SQL Database
b) FileSystem API
c) IndexedDB
d) All of the mentioned
Answer
Answer: c [Reason:] IndexedDB is an object database, not a relational database, and it is much simpler than databases that support SQL queries. It is more powerful, efficient, and robust than the key/value storage provided by the Web Storage API, however.
4. In the IndexedDB database, database is defined as
a) A collection of objects
b) A collection of named object stores
c) Objects collection
d) None of the mentioned
Answer
Answer: b [Reason:] In the IndexedDB API, a database is simply a collection of named object stores.
5. A key path is defined as
a) A url that directs to the value
b) A value that is similar to hash table
c) A value that tells the database how to extract an object’s key from the object
d) None of the mentioned
Answer
Answer: c [Reason:] A key path is defined as a value that tells the database how to extract an object’s key from the object.
6. How does IndexedDB provide atomicity?
a) Grouping among the data
b) Grouping within a transaction
c) Grouping the data
d) None of the mentioned
Answer
Answer: b [Reason:] IndexedDB provides atomicity guarantees: queries and updates to the database are grouped within a transaction so that they all succeed together or all fail together and never leave the database in an undefined partially updated state.
7. Which of the following is a feature of the IndexedDB API?
a) Simplifies the transaction management
b) Need not manage the transaction at all
c) Enhances the storage
d) None of the mentioned
Answer
Answer: a [Reason:] One of the convenient feature of the IndexedDB API is that it simplifies the transaction management.
8. What is the alternate way to search in an IndexedDB API?
a) Key
b) Address
c) Indexes
d) All of the mentioned
Answer
Answer: c [Reason:] In addition to retrieving objects from an object store by their primary key value, you may want to be able to search based on the value of other properties in the object. In order to be able to do this, you can define any number of indexes on the object store.
9. Which is the function used to look up an object?
a) put()
b) set()
c) get()
d) look()
Answer
Answer: c [Reason:] You look up an object by calling the get() method of the object store or store a new object by calling put().
10. Which is the method to look up the objects for a range of keys?
a) lookRange()
b) openCursor()
c) lookall()
d) None of the mentioned
Answer
Answer: b [Reason:] If you want to look up the objects for a range of keys, you create an IDBRange object and pass it to the openCursor() method of the object store.
Database MCQ Set 3
1. ___ is a procedural extension of Oracle – SQL that offers language constructs similar to those in imperative programming languages.
a) SQL
b) PL/SQL
c) Advanced SQL
d) PQL
Answer
Answer: b [Reason:] PL/SQL is an imperative 3GL that was designed specifically for the seamless processing of SQL commands.
2. _____ combines the data manipulating power of SQL with the data processing power of Procedural languages.
a) PL/SQL
b) SQL
c) Advanced SQL
d) PQL
Answer
Answer: a [Reason:] PL/SQL is an imperative 3GL that was designed specifically for the seamless processing of SQL commands.
3. ___ has made PL/SQL code run faster without requiring any additional work on the part of the programmer.
a) SQL Server
b) My SQL
c) Oracle
d) SQL Lite
Answer
Answer: c [Reason:] An Oracle database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information.
4. A line of PL/SQL text contains groups of characters known as
a) Lexical Units
b) Literals
c) Textual Units
d) Identifiers
Answer
Answer: a [Reason:] Lexical items can be generally understood to convey a single meaning, much as a lexeme, but are not limited to single words.
5. We use ________ name PL/SQL program objects and units.
a) Lexical Units
b) Literals
c) Delimiters
d) Identifiers
Answer
Answer: d [Reason:] The database object name is referred to as its identifier.
6. A ___ is an explicit numeric, character, string or Boolean value not represented by an identifier.
a) Comments
b) Literals
c) Delimiters
d) Identifiers
Answer
Answer: b [Reason:] The terms literal and constant value are synonymous and refer to a fixed data value.
7. If no header is specified, the block is said to be an ___ PL/SQL block.
a) Strong
b) Weak
c) Empty
d) Anonymous
Answer
Answer: d [Reason:] The terms literal and constant value are synonymous and refer to a fixed data value.
8. _____ is a sequence of zero or more characters enclosed by single quotes.
a) Integers literal
b) String literal
c) String units
d) String label
Answer
Answer: b [Reason:] The terms literal and constant value are synonymous and refer to a fixed data value.
9. In ___ the management of the password for the account can be handled outside of oracle such as operating system.
a) Database Authentication
b) Operating System Authentication
c) Internal Authentication
d) External Authentication
Answer
Answer: b [Reason:] Database management involves the monitoring, administration, and maintenance of the databases and database groups in your enterprise.
10. In ____ of Oracle, the database administrator creates a user account in the database for each user who needs access.
a) Database Authentication
b) Operating System Authentication
c) Internal Authentication
d) External Authentication
Answer
Answer: a [Reason:] Database management involves the monitoring, administration, and maintenance of the databases and database groups in your enterprise.
Database MCQ Set 4
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
Answer
Answer: a [Reason:] 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)
Answer
Answer: b [Reason:] Avg() is used to find the mean of the values.
3.
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
Answer
Answer: a [Reason:] 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
Answer
Answer: b [Reason:] * 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
Answer
Answer: d [Reason:] 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
Answer
Answer: c [Reason:] 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);
Answer
Answer: a [Reason:] None.
8. The phrase “greater than at least one” is represented in SQL by _____
a) < all
b) < some
c) > all
d) > some
Answer
Answer: d [Reason:] >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)
Answer
Answer: a [Reason:] 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
Answer
Answer: b [Reason:] Exists is used to check for existence of tuples.
Database MCQ Set 5
1. A relation is in ______ if an attribute of a composite key is dependent on an attribute of other composite key.
a) 2NF
b) 3NF
c) BCNF
d) 1NF
Answer
Answer: b [Reason:] A relation is in 3 NF if an attribute of a composite key is dependent on an attribute of other composite key. (If an attribute of a composite key is dependent on an attribute of other composite key then the relation is not in BCNF, hence it has to be decomposed.).
2. What are the desirable properties of a decomposition
a) Partition constraint
b) Dependency preservation
c) Redundancy
d) Security
Answer
Answer: b [Reason:] Lossless join and dependency preserving are the two goals of the decomposition.
3. R (A,B,C,D) is a relation. Which of the following does not have a lossless join dependency preserving BCNF decomposition.
a) A-> B, B-> CD
b) A->B, B->C, C->D
c) AB->C, C->AD
d) A->BCD
Answer
Answer: d [Reason:] This relation gives a relation without any loss in the values.
Class (course id, title, dept name, credits, sec id, semester, YEAR, building, room NUMBER, capacity, TIME slot id) The SET OF functional dependencies that we require TO hold ON class are: course id->title, dept name, credits building, room number->capacity course id, sec id, semester, year->building, room NUMBER, TIME slot id A candidate KEY FOR this schema IS {course id, sec id, semester, YEAR}
4. Consider the above conditions. Which of the following relation holds ?
a) Course id-> title, dept name, credits
b) Title-> dept name, credits
c) Dept name-> credits
d) Cannot be determined
Answer
Answer: a [Reason:] Here course id is not a superkey. Thus, class is not in BCNF.
5. The algorithm that takes a set of dependencies and adds one schema at a time, instead of decomposing the initial schema repeatedly is
a) BCNF algorithm
b) 2NF algorithm
c) 3NF synthesis algorithm
d) 1NF algorithm
Answer
Answer: c [Reason:] The result is not uniquely defined, since a set of functional dependencies can have more than one canonical cover, and, further, in some cases, the result of the algorithm depends on the order in which it considers the dependencies in Fc .
6. The functional dependency can be tested easily on the materialized view, using the constraints ______.
a) Primary key
b) Null
c) Unique
d) Both Null and Unique
Answer
Answer: d [Reason:] Primary key contains both unique and not null constraints .
7. Which normal form is considered adequate for normal relational database design?
a) 2NF
b) 5NF
c) 4NF
d) 3NF
Answer
Answer: d [Reason:] A relational database table is often described as “normalized” if it is in the Third Normal Form because most of the 3NF tables are free of insertion, update, and deletion anomalies .
8. Relation R with an associated set of functional dependencies, F, is decomposed into BCNF. The redundancy (arising out of functional dependencies) in the resulting set of relations is
a) Zero
b) More than zero but less than that of an equivalent 3NF decomposition
c) Proportional to the size of F+
d) Indeterminate
Answer
Answer: b [Reason:] Redundancy in BCNF is low when compared to 3NF. For more details on BCNF .
9. A table has fields F1, F2, F3, F4, and F5, with the following functional dependencies:
F1->F3 F2->F4 (F1,F2)->F5
in terms of normalization, this table is in
a) 1NF
b) 2NF
c) 3NF
d) None of the mentioned
Answer
Answer: a [Reason:] Since the primary key is not given we have to derive the primary key of the table. Using the closure set of attributes we get the primary key as (F1,F2). From functional dependencies, “F1->F3, F2->F4”, we can see that there is partial functional dependency therefore it is not in 1NF. Hence the table is in 1NF.
10. Let R(A,B,C,D,E,P,G) be a relational schema in which the following FDs are known to hold:
AB->CD DE->P C->E P->C B->G
The relation schema R is
a) in BCNF
b) in 3NF, but not in BCNF
c) in 2NF, but not in 3NF
d) not in 2NF
Answer
Answer: d [Reason:] From the closure set of attributes we can see that the key for the relation is AB. The FD B->G is a partial dependency, hence it is not in 2NF.