Database Management System MCQ
Database Management System MCQ
Questions)
2. What is a database?
3. What is DBMS?
d) DBMS stores, modifies and retrieves data
Explanation: Charles Bachman along with his team invented the first DBMS
known as Integrated Data Store (IDS).
Explanation:
The important features of a database management system are:
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 –
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
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;
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
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
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
44. Which of the following functions construct histograms and use buckets
for ranking?
a) Ntil()
b) Newtil()
c) Rank()
d) All of the mentioned
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
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.
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?
1.
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
advertisement
5.
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.
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.
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.
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.
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 course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
d)
Answer: a
Explanation: None.
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 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.
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.
6.
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.
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
2.
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.
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)
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.
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.
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..
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.
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.
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.
Department:
Which of the following is used to create view for these relations together?
a)
Answer: a
Explanation: None.
10.
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
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.
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.
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.
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.
6.
3.
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.
7.
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.
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.
advertisement
ADVERTISEMENT
ADVERTISEMENT
GRANT 'privilege list'
ON 'user/role list'
TO 'relation name or view name';
c)
Answer: a
Explanation: The privilege list allows the granting of several privileges in
one command .
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 ;
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.
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
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.
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.
5.
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)
7.
9.
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.
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.
1. Find the ID, name, dept name, salary for instructors whose salary is
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.
3.
∧ 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 (∧).
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
a) ⇒
calculus
b) =
c) ε
d) All of the mentioned
View Answer
Answer: b
Explanation: The comparison operators are (<, ≤, =, =, >, ≥).
8. Find the names of all instructors in the Physics department together with
the course id of all courses they teach:
a)
∧s = “Fall” ∧ y = “2009”
∧s = “Spring” ∧ y = “2010”
b)
c)
View Answer
Answer: b