DBMS

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 44

Database Questions and Answers Answer:b

– Relational Database and Explanation:Tuple is one entry of the relation


Database Schema with several attributes which are fields.

This set of Database Questions & Answers 4. The term attribute refers to a ___________
focuses on “Relational Database and Database of a table.
Schema” a) Record
b) Column
1. A relational database consists of a collection c) Tuple
of d) Key
a) Tables View Answer
b) Fields
c) Records Answer:b
d) Keys Explanation:Attribute is a specific domain in the
View Answer relation which has entries of all tuples.

Answer:a 5. For each attribute of a relation, there is a set


Explanation:Fields are the column of the of permitted values, called the ________ of that
relation or tables.Records are each row in attribute.
relation.Keys are the constraints in a relation . a) Domain
b) Relation
2. A ________ in a table represents a c) Set
relationship among a set of values. d) Schema
a) Column View Answer
b) Key
c) Row Answer:a
d) Entry Explanation:The values of the attribute should
View Answer be present in the domain.Domain is a set of
values permitted .
Answer:c
Explanation:Column has only one set of 6. Database __________ , which is the logical
values.Keys are constraints and row is one design of the database, and the database
whole set of attributes.Entry is just a piece of _______,which is a snapshot of the data in the
data. database at a given instant in time.
a) Instance, Schema
3. The term _______ is used to refer to a row. b) Relation, Schema
a) Attribute c) Relation, Domain
b) Tuple d) Schema, Instance
c) Field View Answer
d) Instance
View Answer
Answer:d 10. The tuples of the relations can be of
Explanation:Instance is a instance of time and ________ order.
schema is a representation. a) Any
b) Same
7.Course(course_id,sec_id,semester) c) Sorted
Here the course_id,sec_id and semester are d) Constant
__________ and course is a _________ . View Answer
a) Relations, Attribute
b) Attributes, Relation Answer:a
c) Tuple, Relation Explanation:The values only count .The order of
d) Tuple, Attributes the tuples does not matter.
View Answer

Answer:b Database Questions and


Explanation:The relation course has a set of Answers – Keys
attributes course_id,sec_id,semester .
This set of Database Questions & Answers
8. Department (dept name, building, budget) focuses on “Keys”
and Employee (employee_id , name, dept
name,salary) 1. Which one of the following is a set of one or
Here the dept_name attribute appears in both more attributes taken collectively to uniquely
the relations .Here using common attributes in identify a record?
relation schema is one way of relating a) Candidate key
___________ relations. b) Sub key
a) Attributes of common c) Super key
b) Tuple of common d) Foreign key
c) Tuple of distinct View Answer
d) Attributes of distinct
Answer:c
View Answer
Explanation:Super key is the superset of all the
Answer:c keys in a relation.
Explanation:Here the relations are connected by
2. Consider attributes ID , CITY and NAME .
the common attributes.
Which one of this can be considered as a super
9. A domain is atomic if elements of the domain key ?
are considered to be ____________ units. a) NAME
a) Different b) ID
b) Indivisbile c) CITY
c) Constant d) CITY , ID
d) Divisible View Answer
View Answer
Answer:b
Answer:b Explanation:Here the id is the only attribute
Explanation:None.
which can be taken as a key. Other attributes 6. Which one of the following cannot be taken
are not uniquely identified . as a primary key ?
a) Id
3. The subset of super key is a candidate key b) Register number
under what condition ? c) Dept_id
a) No proper subset is a super key d) Street
b) All subsets are super keys View Answer
c) Subset is a super key
d) Each subset is a super key Answer:d
View Answer Explanation:Street is the only attribute which
can occur more than once.
Answer:a
Explanation:The subset of a set cannot be the 7. A attribute in a relation is a foreign key if the
same set.Candidate key is a set from a super _______ key from one relation is used as an
key which cannot be the whole of the super set attribute in that relation .
a) Candidate
4. A _____ is a property of the entire relation, b) Primary
rather than of the individual tuples in which c) Super
each tuple is unique. d) Sub
a) Rows View Answer
b) Key
c) Attribute Answer:b
d) Fields Explanation:The primary key has to be referred
View Answer in the other relation to form a foreign key in
that relation .
Answer:b
Explanation:Key is the constraint which 8. The relation with the attribute which is the
specifies uniqueness. primary key is referenced in another relation.
The relation which has the attribute as primary
5. Which one of the following attribute can be key is called
taken as a primary key ? a) Referential relation
a) Name b) Referencing relation
b) Street c) Referenced relation
c) Id d) Referred relation
d) Department View Answer
View Answer
Answer:b
Answer:c Explanation:None.
Explanation:The attributes name , street and
department can repeat for some tuples.But the 9. The ______ is the one in which the primary
id attribute has to be unique .So it forms a key of one relation is used as a normal attribute
primary key. in another relation .
a) Referential relation
b) Referencing relation
c) Referenced relation d) Compiler
d) Referred relation View Answer
View Answer
Answer:a
Answer:c Explanation:Query language is a method
Explanation:None. through which the database entries can be
accessed.
10. A _________ integrity constraint requires
that the values appearing in specified attributes 2. Student(ID, name, dept name, tot_cred)
of any tuple in the referencing relation also In this query which attribute form the primary
appear in specified attributes of at least one key?
tuple in the referenced relation. a) Name
a) Referential b) Dept
b) Referencing c) Tot_cred
c) Specific d) ID
d) Primary View Answer
View Answer
Answer:d
Answer:a Explanation:The attributes name ,dept and
Explanation:A relation, say r1, may include tot_cred can have same values unlike ID .
among its attributes the primary key of another
relation, say r2. This attribute is called a foreign 3. Which one of the following is a procedural
key from r1, referencing r2. The relation r1 is language ?
also called the referencing relation of the a) Domain relational calculus
foreign key dependency, and r2 is called the b) Tuple relational calculus
referenced relation of the foreign key. c) Relational algebra
d) Query language
View Answer
Database Questions and
Answer:c
Answers – Relational Query
Explanation:Domain and Tuple relational
Operations and Relational calculus are non-procedural language.Query
Operators language is a method through which the
database entries can be accessed.
This set of Database Questions & Answers
focuses on “Relational Query Operations and 4. The_____ operation allows the combining of
Relational Operators” two relations by merging pairs of tuples, one
from each relation, into a single tuple.
1. Using which language can a user request
a) Select
information from a database ?
b) Join
a) Query
c) Union
b) Relational
d) Intersection
c) Structural
View Answer
Answer:b in both result sets.
Explanation:Join finds the common tuple in the a) Union
relations and combines it. b) Intersect
c) Difference
5. The result which operation contains all pairs d) Projection
of tuples from the two relations, regardless of View Answer
whether their attribute values match.
a) Join Answer:b
b) Cartesian product Explanation:The union operator gives the result
c) Intersection which is the union of two queries and difference
d) Set difference is the one where query which is not a part of
View Answer second query .

Answer:b 9. A ________ is a pictorial depiction of the


Explanation:Cartesian product is the schema of a database that shows the relations
multiplication of all the values in the attributes. in the database, their attributes, and primary
keys and foreign keys.
6. The _______operation performs a set union a) Schema diagram
of two “similarly structured” tables b) Relational algebra
a) Union c) Database diagram
b) Join d) Schema flow
c) Product View Answer
d) Intersect
View Answer Answer:a
Explanation:None.
Answer:a
Explanation:Union just combines all the values 10. The _________ provides a set of operations
of relations of same attributes. that take one or more relations as input and
return a relation as an output.
7. The most commonly used operation in a) Schematic representation
relational algebra for projecting a set of tuple b) Relational algebra
from a relation is c) Scheme diagram
a) Join d) Relation flow
b) Projection View Answer
c) Select
d) Union Answer:b
View Answer Explanation:None.

Answer:c
Explanation:Select is used to view the tuples of Database Questions and
the relation with or without some constraints. Answers – SQL Basics and
8. The _______ operator takes the results of SQL Data Definition
two queries and returns only rows that appear
This set of Database Questions & Answers focuses c) View
on ” SQL Basics and SQL Data Definition” d) Integrity constraint
View Answer
1. Which one of the following is used to define the
structure of the relation ,deleting relations and Answer:a
relating schemas ? Explanation: Select operation just shows the
a) DML(Data Manipulation Langauge) required fields of the relation. So it forms a DML
b) DDL(Data Definition Langauge)
c) Query 5. The basic data type char(n) is a _____ length
d) Relational Schema character string and varchar(n) is _____ length
View Answer character.
a) Fixed, equal
Answer:b b) Equal, variable
Explanation: Data Definition language is the c) Fixed, variable
language which performs all the operation in d) Variable, equal
defining structure of relation. View Answer

2. Which one of the following provides the ability to Answer:c


query information from the database and to insert Explanation: Varchar changes its length accordingly
tuples into, delete tuples from, and modify tuples in whereas char has a specific length which has to be
the database ? filled by either letters or spaces .
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge) 6. An attribute A of datatype varchar(20) has the
c) Query value “Avi” . The attribute B of datatype char(20) has
d) Relational Schema value ”Reed” .Here attribute A has ____ spaces and
View Answer attribute B has ____ spaces .
a) 3, 20
Answer:a b) 20, 4
Explanation: DML performs change in the values of c) 20 , 20
the relation . d) 3, 4
View Answer
3. Create table employee (name varchar ,id integer)
What type of statement is this ? Answer:a
a) DML Explanation: Varchar changes its length accordingly
b) DDL whereas char has a specific length which has to be
c) View filled by either letters or spaces.
d) Integrity constraint
View Answer 7. To remove a relation from an SQL database, we
use the ______ command.
Answer:b a) Delete
Explanation:Data Definition language is the language b) Purge
which performs all the operation in defining c) Remove
structure of relation. d) Drop table
View Answer
4. Select * from employee
What type of statement is this? Answer:d
a) DML Explanation: Drop table deletes the whole structure
b) DDL
of the relation .purge removes the table which
Name
cannot be obtained again.

8. Delete from r; r – relation Annie


This command performs which of the following
action ?
Bob
a) Remove relation
b) Clear relation entries
c) Delete fields Callie
d) Delete rows
View Answer Derek
Answer:b
Explanation: Delete command removes the entries in Which of these query will display the the table
the table. given above ?
a) Select employee from name
9. Insert into instructor values (10211, ’Smith’, b) Select name
’Biology’, 66000);
c) Select name from employee
What type of statement is this ?
d) Select employee
a) Query
View Answer
b) DML
c) Relational
Answer:c
d) DDL
Explanation:The field to be displayed is included
View Answer
in select and the table is included in the from
Answer:b clause.
Explanation: The values are manipulated .So it is a
DML . 2. Select ________ dept_name
from instructor;
10. Updates that violate __________ are disallowed . Here which of the following displays the unique
a) Integrity constraints
values of the column ?
b) Transaction control
a) All
c) Authorization
d) DDL constraints
b) From
View Answer c) Distinct
d) Name
Answer:a View Answer
Explanation:Integrity constraint has to be
maintained in the entries of the relation . Answer:c
Explanation:Distinct keyword selects only the
entries that are unique.
Database Questions and
Answers – SQL Queries 3. The ______ clause allows us to select only
those rows in the result relation of the ____
This set of Database Questions & Answers clause that satisfy a specified predicate.
focuses on “SQL Queries” a) Where, from
1. b) From, select
c) Select, from instructor_id=course_id;
d) From, where b) Select name, course_id from instructor
View Answer natural join teaches;
c) Select name ,course_id from instructor;
Answer:a d) Select course_id from instructor join teaches;
Explanation:Where selects the rows on a View Answer
particular condition.From gives the relation
which involves the operation. Answer:b
Explanation:Join clause joins two tables by
4. Select ID, name, dept name, salary * 1.1 matching the common column .
where instructor;
The query given below will not give an error. 7. Select * from employee where salary>10000
Which one of the following has to be replaced and dept_id=101;
to get the desired output? Which of the following fields are displayed as
a) Salary*1.1 output?
b) ID a) Salary, dept_id
c) Where b) Employee
d) Instructor c) Salary
View Answer d) All the field of employee relation
View Answer
Answer:c
Explanation:Where selects the rows on a Answer:d
particular condition.From gives the relation Explanation:Here * is used to select all the fields
which involves the operation. Since Instructor is of the relation .
a relation it has to have from clause.
8.
5. The ________ clause is used to list the
attributes desired in the result of a query. Employee_id Name Salary
a) Where
b) Select 1001 Annie 6000
c) From
d) Distinct 1009 Ross 4500
View Answer
1018 Zeith 7000
Answer:b
Explanation:None This is Employee table.
6. Select name, course_id Select * from employee where
from instructor, teaches employee_id>1009;
where instructor_ID= teaches_ID; Which of the following employee_id will be
This Query can be replaced by which one of the displayed?
following ? a) 1009, 1001, 1018
a) Select name,course_id from b) 1009, 1018
teaches,instructor where c) 1001
d) 1018 1. Select name ____ instructor name, course id
View Answer from instructor, teaches
where instructor.ID= teaches.ID;
Answer:d Which keyword must be used here to rename
Explanation:Greater than symbol does not the field name ?
include the given value unlike >=. a) From
9. Which of the following statements contains b) Rename
an error? c) As
A) Select * from emp where empid = 10003; d) Join
B) Select empid from emp where empid = View Answer
10006; Answer:c
C) Select empid from emp; Explanation:As keyword is used to rename.
D) Select empid where empid = 1009 and
lastname = ‘GELLER’; 2. Select * from employee where
View Answer dept_name=”Comp Sci”;
In the SQL given above there is an error .
Answer:d Identify the error .
Explanation:This query do not have from clause a) Dept_name
which specifies the relation from which the b) Employee
values has to be selected . c) “Comp Sci”
10. Insert into employee _____ d) From
(1002,Joey,2000); View Answer
In the given query which of the keyword has to Answer:c
be inserted ? Explanation:For any string operations single
a) Table quoted(‘) must be used to enclose.
b) Values
c) Relation 3. Select emp_name
d) Field from department
View Answer where dept_name like ’ _____ Computer
Science’;
Answer:b Which one of the following has to be added into
Explanation:Value keyword has to be used to the blank to select the dept_name which has
insert the values into the table. Computer Science as its ending string ?
a) %
Database Questions and b) _
c) ||
Answers – Basic SQL
d) $
Operations View Answer
This set of Database Questions & Answers
focuses on “Basic SQL Operations”
Answer:a Answer:c
Explanation:The % character matches any Explanation:None.
substring.
7. Select name
4. ’_ _ _ ’ matches any string of ______ three from instructor
characters. ’_ _ _ %’ matches any string of at where salary <= 100000 and salary >= 90000;
______ three characters. This query can be replaced by which of the
a) Atleast, Exactly following ?
b) Exactly, Atleast a) Select name
c) Atleast, All from instructor
d) All , Exactly where salary between 90000 and 100000;
View Answer b) Select name
from employee
Answer:b where salary <= 90000 and salary>=100000;
Explanation:None. c) Select name
5. Select name from employee
from instructor where salary between 90000 and 100000;
where dept name = ’Physics’ d) Select name
order by name; from instructor
By default, the order by clause lists items in where salary between 100000 and 90000;
______ order. View Answer
a) Descending Answer:a
b) Any Explanation: SQL includes a between
c) Same comparison operator to simplify where clauses
d) Ascending that specify that a value be less than or equal to
View Answer some value and greater than or equal to some
Answer:d other value.
Explanation:Specification of descending order is 8. Select instructor.*
essential but it not for ascending. from instructor, teaches
6. Select * where instructor.ID= teaches.ID;
from instructor This query does which of the following
order by salary ____, name ___; operation?
To display the salary from greater to smaller a) All attributes of instructor and teaches are
and name in ascending order which of the selected
following options should be used ? b) All attributes of instructor are selected on the
a) Ascending, Descending given condition
b) Asc, Desc c) All attributes of teaches are selected on given
c) Desc, Asc condition
d) Descending, Ascending d) Only the some attributes from instructed and
View Answer teaches are selected
View Answer
Answer:b Answer:b
Explanation:The asterisk symbol “ * ” can be Explanation:Union operator combines the
usedin the select clause to denote “all relations.
attributes.”
2. The intersection operator is used to get the
9. In SQL the spaces at the end of the string are _____ tuples.
removed by _______ function . a) Different
a) Upper b) Common
b) String c) All
c) Trim d) Repeating
d) Lower View Answer
View Answer
Answer:b
Answer:c Explanation:Intersection operator ignores
Explanation: The syntax of trim is Trim(s); where unique tuples and takes only common ones.
s-string .
3. The union operation automatically
10. _____ operator is used for appending two __________, unlike the select clause.
strings. a) Adds tuples
a) & b) Eliminates unique tuples
b) % c) Adds common tuples
c) || d) Eliminates duplicate
d) _ View Answer
View Answer
Answer:d
Answer:c Explanation:None.
Explanation: || is the concatenation operator.
4. If we want to retain all duplicates, we must
write ________ in place of union.
Database Questions and a) Union all
Answers – Set Operations b) Union some
c) Intersect all
This set of Database Questions & Answers d) Intersect some
focuses on “Set Operations” View Answer
1. The union operation is represented by Answer:a
a) ∩ Explanation:Union all will combine all the tuples
b) U including duplicates.
c) -
d) * 5. (Select course id
View Answer from section
where semester = ’Fall’ and year= 2009)
except
(select course id
from section c) Having
where semester = ’Spring’ and year= 2010); d) Order by
This query displays View Answer
a) Only tuples from second part
b) Only tuples from the first part which has the Answer:c
tuples from second part Explanation:Having is used to provide additional
c) Tuples from both the parts aggregate filtration to the query.
d) Tuples from first part which do not have 9. _________ joins are SQL server default
second part a) Outer
View Answer b) Inner
Answer:d c) Equi
Explanation:Except keyword is used to ignore d) None of the mentioned
the values. View Answer

6. For like predicate which of the following is Answer:b


true. Explanation:It is optional to give the inner
i) % matches zero of more characters. keyword with join as it is default .
ii) _ matches exactly one character. 10. The _____________ is essentially used to
a) i-only search for patterns in target string.
b) ii-only a) Like Predicate
c) Both of the mentioned b) Null Predicate
d) None of the mentioned c) In Predicate
View Answer d) Out Predicate
Answer:a View Answer
Explanation:% is used with like and _ is used to Answer:a
fill in the character. Explanation:Like predicate matches the string in
7. The number of attributes in relation is called the given pattern.
as its Database Questions and Answers – Null Values
a) Cardinality Operations
b) Degree
c) Tuples This set of Database Questions &
d) Entity
Answers focuses on “Null Values
View Answer
Operations”
Answer:b
Explanation:None. 1. A _____ indicates an absent value that may
exist but be unknown or that may not exist at
8. _____ clause is an additional filter that is all.
applied to the result. a) Empty tuple
a) Select b) New value
b) Group-by c) Null value
d) Old value 5. In a employee table to include the attributes
View Answer whose value always have some value which of
the following constraint must be used ?
2. If the attribute phone number is included in a) Null
the relation all the values need not be entered b) Not null
into the phone number column . This type of c) Unique
entry is given as d) Distinct
a) 0 View Answer
b) -
c) Null Answer:b
d) Empty space Explanation:Not null constraint removes the
View Answer tpules of null values.

Answer:c 6. Using the ______ clause retains only one


Explanation:Null is used to represent absence of copy of such identical tuples.
a value. a) Null
b) Unique
3. The predicate in a where clause can involve c) Not null
Boolean operations such as and.The result of d) Distinct
true and unknown is_______, false and View Answer
unknown is _____, while unknown and
unknown is _____. Answer:d
a) Unknown, unknown, false Explanation:Unique is a constraint.
b) True, false, unknown
c) True, unknown, unknown 7. Create table employee (id integer,name
d) Unknown, false, unknown varchar(20),salary not null);
View Answer Insert into employee values (1005,Rach,0);
Insert into employee values (1007,Ross, );
Answer:d Insert into employee values (1002,Joey,335);
Explanation:None. Some of these insert statements will produce
an error. Identify the statement.
4. Select name a) Insert into employee values (1005,Rach,0);
from instructor b) Insert into employee values (1002,Joey,335);
where salary is not null; c) Insert into employee values (1007,Ross, );
Selects d) Both a and c
a) Tuples with null value View Answer
b) Tuples with no null values
c) Tuples with any salary Answer:c
d) All of the mentioned Explanation:Not null constraint is specified
View Answer which means sone value (can include 0 also)
should be given.
Answer:b
Explanation:Not null constraint removes the 8. The primary key must be
tpules of null values. a) Unique
b) Not null This set of Database Questions & Answers
c) Both a and b focuses on “Aggregate Functions and Nested
d) Either a or b Subqueries”
View Answer
1. Aggregate functions are functions that take a
Answer:c ___________ as input and return a single value.
Explanation:Primary key must satisfy unique a) Collection of values
and not null condition for sure. b) Single value
c) Aggregate value
9. You attempt to query the database with this d) Both a & b
command: (25) View Answer
select nvl (100 / quantity, none)
from inventory; Answer:a
Why does this statement cause an error when Explanation:None.
QUANTITY values are null?
a. The expression attempts to divide by a null 2. Select __________
value. from instructor
b. The data types in the conversion function are where dept name= ’Comp. Sci.’;
incompatible. Which of the following should be used to find
c. The character string none should be enclosed the mean of the salary ?
in single quotes (‘ ‘). a) Mean(salary)
d. A null value used in an expression cannot be b) Avg(salary)
converted to an actual value c) Sum(salary)
View Answer d) Count(salary)
View Answer
Answer:a
Explanation: The expression attempts to divide Answer:b
by a null value is errorneous in sql. Explanation:Avg() is used to find the mean of
the values.
10. The result of _____unknown is unknown.
a) Xor 3. Select count (____ ID)
b) Or from teaches
c) And where semester = ’Spring’ and year = 2010;
d) Not If we do want to eliminate duplicates, we use
View Answer the keyword ______in the aggregate
expression.
Answer:d a) Distinct
Explanation:Since unknown does not hold any b) Count
value the value cannot have a reverse value. c) Avg
d) Primary key
Database Questions and Answers – Aggregate View Answer
Functions and Nested Subqueries – 1
Answer:a 7. Which of the following should be used to find
Explanation:Distinct keyword is used to select all the courses taught in the Fall 2009 semester
only unique items from the relation. but not in the Spring 2010 semester .
a) Select distinct course id
4. All aggregate functions except _____ ignore from section
null values in their input collection. where semester = ’Fall’ and year= 2009 and
a) Count(attribute) course id not in (select course id
b) Count(*) from section
c) Avg where semester = ’Spring’ and year= 2010);
d) Sum b) Select distinct course_id
View Answer from instructor
Answer:b where name not in (’Fall’, ’Spring’);
Explanation:* is used to select all values c) (Select course id
including null. from section
where semester = ’Spring’ and year= 2010)
5. A Boolean data type that can take values d) Select count (distinct ID)
true, false, and________ . from takes
a) 1 where (course id, sec id, semester, year) in
b) 0 (select course id, sec id, semester, year
c) Null from teaches
d) Unknown where teaches.ID= 10101);
View Answer View Answer

Answer:d Answer:a
Explanation:Unknown values do not take null Explanation:None.
value but it is not known.
8. The phrase “greater than at least one” is
6. The ____ connective tests for set represented in SQL by _____.
membership, where the set is a collection of a) < all
values produced by a select clause. The ____ b) < some
connective tests for the absence of set c) > all
membership. d) > some
a) Or, in View Answer
b) Not in, in
c) In, not in Answer:d
d) In, or Explanation: >some takes atlest one value
View Answer above it .

Answer:c 9. Which of the following is used to find all


Explanation:In checks if the query has the value courses taught in both the Fall 2009 semester
but not in checks if it does not have the value. and in the Spring 2010 semester .
a) Select course id
from section as S
where semester = ’Fall’ and year= 2009 and This set of Database Questions & Answers
exists (select * focuses on “Aggregate Functions and Nested
from section as T Subqueries”
where semester = ’Spring’ and year= 2010 and
S.course id= T.course id); 1. Select dept_name, ID, avg (salary)
b) Select name from instructor
from instructor group by dept_name;
where salary > some (select salary This statement is erroneous because
from instructor a) Avg(salary) should not be selected
where dept name = ’Biology’); b) Dept_id should not be used in group by
c) Select count (distinct ID) clause
from takes c) Misplaced group by clause
where (course id, sec id, semester, year) in d) Group by clause is not valid in this query
(select course id, sec id, semester, year View Answer
from teaches Answer:b
where teaches.ID= 10101); Explanation:Any attribute that is not present in
d) (Select course id the group by clause must appear only inside an
from section aggregate function if it appears in the select
where semester = ’Spring’ and year= 2010) clause, otherwise the query is treated as
View Answer erroneous.
Answer:a 2. SQL applies predicates in the _______ clause
Explanation:None. after groups have been formed, so aggregate
10. We can test for the nonexistence of tuples functions may be used.
in a subquery by using the _____ construct. a) Group by
a) Not exist b) With
b) Not exists c) Where
c) Exists d) Having
d) Exist View Answer
View Answer Answer:b
Answer:b Explanation:The with clause provides away of
Explanation:Exists is used to check for existence defining a temporary relation whose definition
of tuples. is available only to the query in which the with
clause occurs..

Database Questions and 3. Aggregate functions can be used in the select


list or the_______clause of a select statement
Answers – Aggregate
or subquery. They cannot be used in a ______
Functions and Nested clause.
Subqueries – 2 a) Where, having
b) Having, where
c) Group by, having In the query given above which one of the
d) Group by, where following is a temporary relation ?
View Answer a) Budget
b) Department
4. The ________ keyword is used to access c) Value
attributes of preceding tables or subqueries in d) Max_budget
the from clause. View Answer
a) In
b) Lateral Answer:d
c) Having Explanation:With clause creates a temporary
d) With relation.
View Answer
7. Subqueries cannot:
Answer:b a) Use group by or group functions
Explanation:Eg : Select name, salary, avg salary b) Retrieve data from a table different from the
from instructor I1, lateral (select avg(salary) as one in the outer query
avg salary c) Join tables
from instructor I2 d) Appear in select, update, delete, insert
where I2.dept name= I1.dept name); statements.
Without the lateral clause, the subquery cannot View Answer
access the correlation variable
I1 from the outer query. Answer:c
Explanation:None.
5. Which of the following creates temporary
relation for the query on which it is defined ? 8. Which of the following is not a aggregate
a) With function ?
b) From a) Avg
c) Where b) Sum
d) Select c) With
View Answer d) Min
View Answer
Answer:a
Explanation:The with clause provides away of Answer:c
defining a temporary relation whose definition Explanation:With is used to create temporary
is available only to the query in which the with relation and its not a aggregate function.
clause occurs.. 9. The EXISTS keyword will be true if:
6. With max_budget (value) as a) Any row in the subquery meets the condition
(select max(budget) only.
from department) b) All rows in the subquery fail the condition
select budget only.
from department, max_budget c) Both of these two conditions are met.
where department.budget = max budget.value; d) Neither of these two conditions is met.
View Answer
Answer:a Answer:a
Explanation:EXISTS keyword checks for Explanation:Here P gives the condition for
existance of condition. deleting specific rows.

10. How can you find rows that do not match 3. Which one of the following deletes all the
some specified condition? entries but keeps the structure of the relation .
a) EXISTS a) Delete from r where P;
b) Double use of NOT EXISTS b) Delete from instructor where dept name=
c) NOT EXISTS ’Finance’;
d) None of the mentioned is correct. c) Delete from instructor where salary between
View Answer 13000 and 15000;
d) Delete from instructor;
Answer:b View Answer
Explanation:None.
Answer:d
Explanation:Absence of condition deletes all
Database Questions and rows.
Answers – Modification of
Database 4. Which of the following is used to insert a
tuple from another relation .
This set of Database Questions & Answers a) Insert into course (course id, title, dept name,
focuses on “Modification of Database” credits)
values (’CS-437’, ’Database Systems’, ’Comp.
1. A Delete command operates on ______
Sci.’, 4);
relation.
b) Insert into instructor
a) One
select ID, name, dept name, 18000
b) Two
from student
c) Several
where dept name = ’Music’ and tot cred > 144;
d) Null
c) Insert into course values (’CS-437’, ’Database
View Answer
Systems’, ’Comp. Sci.’, 4);
Answer:a d) Not possible
Explanation:Delete can delete from only one View Answer
table at a time.
Answer:b
2. Delete from r where P; Explanation:Using select statement in insert will
The above command include rows which are the result of the
a) Deletes a particular tuple from the relation selection.
b) Deletes the relation
5. Which of the following deletes all tuples in
c) Clears all entries from the relation
the instructor relation for those instructors
d) All of the mentioned
associated with a department located in the
View Answer
Watson building which is in department
relation.
a) Delete from instructor b) Where
where dept_name in ‘Watson’; c) Case
b) Delete from department d) When
where building=’Watson’; View Answer
c) Delete from instructor
where dept_name in (select dept name Answer:c
from department Explanation:The case statements can add the
where building = ’Watson’); order of updating tuples.
d) Both a and c 9. Which of the following is the correct format
View Answer for case statements .
Answer:c a) Case
Explanation:The query must include when pred1 … result1
building=watson condition to filter the tuples. when pred2 … result2
...
6. Update instructor when predn … resultn
_____ salary= salary * 1.05; else result0
Fill in with correct keyword to update the end
instructor relation. b) Case
a) Where when pred1 then result1
b) Set when pred2 then result2
c) In ...
d) Select when predn then resultn
View Answer else result0
end
Answer:b c) Case
Explanation:Set is used to update the particular when pred1 then result1
value. when pred2 then result2
7. _________ are useful in SQL update ...
statements,where they can be used in the set when predn then resultn
clause. else result0
a) Multiple queries d) All of the mentioned
b) Sub queries View Answer
c) Update Answer:b
d) Scalar subqueries Explanation:None.
View Answer
10. Which of the following relation updates all
Answer:d instructors with salary over $100,000 receive a
Explanation:None. 3 percent raise, whereas all others receive a 5
8. The problem of ordering the update in percent raise.
multiple update is avoided using a) Update instructor
a) Set set salary = salary * 1.03
where salary > 100000; Answer:a
update instructor Explanation:On gives the condition for the join
set salary = salary * 1.05 expression.
where salary <= 100000;
b) Update instructor 2. Which of the join operations do not preserve
set salary = salary * 1.05 non matched tuples.
where salary < (select avg (salary) a) Left outer join
from instructor); b) Right outer join
c) Update instructor c) Inner join
set salary = case d) Natural join
when salary <= 100000 then salary * 1.05 View Answer
else salary * 1.03 Answer:c
end Explanation:INNER JOIN: Returns all rows when
d) Both a and c there is at least one match in BOTH tables.
View Answer
3. Select *
Answer:d from student join takes using (ID);
Explanation:The order of the two update The above query is equivalent to
statements is important. If we changed the a) Select *
order of the two statements, an instructor with from student inner join takes using (ID);
a salary just under $100,000 would receive an b) Select *
over 8 percent raise. SQL provides a case from student outer join takes using (ID);
construct that we can use to perform both the c) Select *
updates with a single update statement, from student left outer join takes using (ID);
avoiding the problem with the order of updates. d) Both a and b
View Answer
Database Questions and Answer:a
Answers – Join Expressions Explanation:Join can be replaced by inner join.

This set of Database Questions & Answers 4. What type of join is needed when you wish to
focuses on “Join Expressions” include rows that do not have matching values?
a) Equi-join
1. The____condition allows a general predicate
b) Natural join
over the relations being joined.
c) Outer join
a) On
d) All of the mentioned
b) Using
View Answer
c) Set
d) Where Answer:c
View Answer 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 from the right table, and the matched rows
join? from the left table.
a) One
b) Two 9. The operation which is not considered a basic
c) Three operation of relational algebra is
d) All of the mentioned a) Join
View Answer b) Selection
c) Union
Answer:d d) Cross product
Explanation:Join can combine multiple tables. View Answer

6. Which are the join types in join condition: Answer:a


a) Cross join Explanation:None.
b) Natural join
c) Join with USING clause 10. In SQL the statement select * from R, S is
d) All of the mentioned equivalent to
View Answer a) Select * from R natural join S
b) Select * from R cross join S
Answer:d c) Select * from R union join S
Explanation:There are totally four join types in d) Select * from R inner join S
SQL. View Answer

7. How many join types in join condition: Answer:b


a) 2 Explanation:None.
b) 3
c) 4
d) 5
Database Questions and
View Answer Answers – Views
Answer:d This set of Database Questions & Answers
Explanation:Types are inner join,left outer focuses on “Views”
join,right outer join,full join,cross join.
1. Which of the following creates a virtual
8. Which join refers to join records from the relation for storing the query ?
right table that have no matching key in the left a) Function
table are include in the result set: b) View
a) Left outer join c) Procedure
b) Right outer join d) None of the mentioned
c) Full outer join View Answer
d) Half outer join
Answer:b
View Answer
Explanation:Any such relation that is not part of
Answer:b the logical model, but is made visible to a
Explanation:RIGHT OUTER JOIN: Return all rows user as a virtual relation, is called a view.
2. Which of the following is the syntax for views d) Cannot determine
where v is view name ? View Answer
a) Create view v as “query name”;
b) Create “query expression” as view; Answer:a
c) Create view v as “query expression”; Explanation:None.
d) Create view “query expression”; 6. SQL view is said to be updatable (that is,
View Answer inserts, updates or deletes can be applied on
Answer:c the view) if which of the following conditions
Explanation: is any legal query expression. The are satisfied by the query defining the view?
view name is a) The from clause has only one database
represented by v. relation.
b) The query does not have a group by or
3. Select course_id having clause.
from physics_fall_2009 c) The select clause contains only attribute
where building= ’Watson’; names of the relation, and does not have any
Here the tuples are selected from the expressions, aggregates, or distinct
view.Which one denotes the view. specification.
a) Course_id d) All of the mentioned
b) Watson View Answer
c) Building
d) physics_fall_2009 Answer:d
View Answer Explanation:All of the conditions must be
satisfied to update the view in sql.
Answer:c
Explanation:View names may appear in a query 7. Which of the following is used at the end of
any place where a relation name may appear. the view to reject the tuples which do not
satisfy the condition in where clause ?
4. Materialised views make sure that a) With
a) View definition is kept stable b) Check
b) View definition is kept up-to-date c) With check
c) View definition is verified for error d) All of the mentioned
d) View is deleted after specified time View Answer
View Answer
Answer:c
Answer:b Explanation:Views can be defined with a with
Explanation:None. check option clause at the end of the view
definition; then, if a tuple inserted into the view
5. Updating the value of the view does not satisfy the view’s where clause
a) Will affect the relation from which it is condition, the insertion is rejected by the
defined database system.
b) Will not change the view definition
c) Will not affect the relation from which it is 8. Consider the two relations instructor and
defined department
Nam 9. For the view Create view instructor_info as
ID Dept_name Salary select ID, name, building
e
from instructor, department
where instructor.dept name= department.dept
1001 Ted Finance 10000
name;
If we insert tuple into the view as insert into
1002 Bob Music 20000
instructor info values (’69987’, ’White’,
’Taylor’);
1003 Ron Physics 50000 What will be the values of the other attributes
in instructor and department relations?
Department: a) Default value
b) Null
Dept_name Building Budget c) Error statement
d) 0
Biology Watson 40000 View Answer

Answer:b
Chemistry Painter 30000
Explanation:The values take null if there is no
constraint in the attribute else it is a Erroneous
Music Taylor 50000
statement.

Which of the following is used to create view 10. Create view faculty as
for these relations together? Select ID, name, dept name
a) Create view instructor_info as from instructor;
select ID, name, building Find the error in this query .
from instructor, department a) Instructor
where instructor.dept name= department.dept b) Select
name; c) View …as
b) Create view instructor_info d) None of the mentioned
select ID, name, building View Answer
from instructor, department;
c) Create view instructor_info as Answer:d
select ID, name, building Explanation:Syntax is – create view v as ;.
from instructor;
d) Create view instructor_info as Database Questions and
select ID, name, building
from department;
Answers – Transactions
View Answer This set of Database Questions & Answers
focuses on “Transactions”
Answer:a
Explanation:None. 1. A _________ consists of a sequence of query
and/or update statements.
a) Transaction
b) Commit d) No action
c) Rollback View Answer
d) Flashback
View Answer Answer:d
Explanation:Once a transaction has executed
Answer:a commit work, its effects can no longer be
Explanation:Transaction is a set of operation undone by rollback work.
until commit.
5. In case of any shut down during transaction
2. Which of the following makes the transaction before commit which of the following
permanent in the database ? statement is done automatically ?
a) View a) View
b) Commit b) Commit
c) Rollback c) Rollback
d) Flashback d) Flashback
View Answer View Answer

Answer:b Answer:c
Explanation:Commit work commits the current Explanation:Once a transaction has executed
transaction. commit work, its effects can no longer be
undone by rollback work.
3. In order to undo the work of transaction after
last commit which one should be used ? 6. In order to maintain the consistency during
a) View transactions database provides
b) Commit a) Commit
c) Rollback b) Atomic
d) Flashback c) Flashback
View Answer d) Retain
View Answer
Answer:c
Explanation:Rollback work causes the current Answer:b
transaction to be rolled back; that is, it undoes Explanation:By atomic , either all the effects of
all the updates performed by the SQL the transaction are reflected in the database, or
statements in the transaction. none are (after rollback).

4. Consider the following action: 7. Transaction processing is associated with


Transaction….. everything below except
Commit; a) Conforming a action or triggering a response
Rollback; b) Producing detail summary or exception
What does Rollback do? report
a) Undoes the transactions before commit c) Recording a business activity
b) Clears all transactions d) Maintaining a data
c) Redoes the transactions before commit View Answer
Answer:a This set of Database Questions & Answers
Explanation:None. focuses on “Integrity Constraints”

8. A transaction completes its execution is said 1. To include integrity constraint in a existing


to be relation use :
a) Committed a) Create table
b) Aborted b) Modify table
c) Rolled back c) Alter table
d) Failed d) Drop table
View Answer View Answer

Answer:a Answer:c
Explanation:A complete transaction always Explanation:SYNTAX – alter table table-name
commits. add constraint , where constraint can be any
constraint on the relation.
9. Which of the following is used to get back all
the transactions back after rollback ? 2. Which of the following is not a integrity
a) Commit constraint ?
b) Rollback a) Not null
c) Flashback b) Positive
d) Redo c) Unique
View Answer d) Check ‘predicate’
View Answer
Answer:c
Explanation:None. Answer:b
Explanation:Positive is a value and not a
10. ______ will undo all statements up to constraint.
commit?
a) Transaction 3. Create table Employee(Emp_id numeric not
b) Flashback null, Name varchar(20) , dept_name
c) Rollback varchar(20), Salary numeric
d) Abort unique(Emp_id,Name));
View Answer insert into Employee values(1002, Ross, CSE,
10000)
Answer:c insert into Employee
Explanation:Flashback will undo all the values(1006,Ted,Finance, );
statements and Abort will terminate the insert into Employee
operation. values(1002,Rita,Sales,20000);
What will be the result of the query?
Database Questions and a) All statements executed
b) Error in create statement
Answers – Integrity
c) Error in insert into Employee
Constraints values(1006,Ted,Finance, );
d) Error in insert into Employee 6. Create table course
values(1008,Ross,Sales,20000); (...
View Answer foreign key (dept name) references department
. . . );
Answer:d Which of the following is used to delete the
Explanation:The not null specification prohibits entries in the referenced table when the tuple is
the insertion of a null value for the attribute. deleted in course table?
The unique specification says that no two tuples a) Delete
in the relation can be equal on all the listed b) Delete cascade
attributes. c) Set null
4. Create table Manager(ID numeric,Name d) All of the mentioned
varchar(20),budget numeric,Details View Answer
varchar(30)); Answer:b
Inorder to ensure that the value of budget is Explanation:The delete “cascades” to the
non-negative which of the following should be course relation, deletes the tuple that refers to
used? the department that was deleted.
a) Check(budget>0)
b) Check(budget<0) 7. Domain constraints, functional dependency
c) Alter(budget>0) and referential integrity are special forms of
d) Alter(budget<0) _________.
View Answer a) Foreign key
b) Primary key
Answer:d c) Assertion
Explanation:A common use of the check clause d) Referential constraint
is to ensure that attribute values satisfy View Answer
specified conditions, in effect creating a
powerful type system. Answer:c
Explanation:An assertion is a predicate
5. Foreign key is the one in which the ________ expressing a condition we wish the database to
of one relation is referenced in another relation. always satisfy.
a) Foreign key
b) Primary key 8. Which of the following is the right syntax for
c) References assertion?
d) Check constraint a) Create assertion 'assertion-name' check
View Answer 'predicate';
b) Create assertion check 'predicate' 'assertion-
Answer:b name';
Explanation:The foreign-key declaration c) Create assertions 'predicates';
specifies that for each course tuple, the d) All of the mentioned
department name specified in the tuple must View Answer
exist in the department relation.
Answer:a b) yyyy/mm/dd
Explanation:None. c) dd/mm/yy
d) yy/dd/mm
9. Data integrity constraints are used to: View Answer
a) Control who is allowed access to the data
b) Ensure that duplicate records are not entered Answer:b
into the table Explanation:yyyy/mm/dd is the default format
c) Improve the quality of data entered for a in sql .
specific property (i.e., table column)
d) Prevent users from changing the values 2. An ________ on an attribute of a relation is a
stored in the table data structure that allows the database system
View Answer to find those tuples in the relation that have a
specified value for that attribute efficiently,
Answer:c without scanning through all the tuples of the
Explanation:None. relation.
a) Index
10. Which of the following can be addressed by b) Reference
enforcing a referential integrity constraint? c) Assertion
a) All phone numbers must include the area d) Timestamp
code View Answer
b) Certain fields are required (such as the email
address, or phone number) before the record is Answer:a
accepted Explanation:Index is the reference to the tuples
c) Information on the customer must be known in a relation.
before anything can be sold to that customer
d) When entering an order quantity, the user 3. Create index studentID_index on student(ID);
must input a number and not some text (i.e., 12 Here which one denotes the relation for which
rather than ‘a dozen’) index is created ?
View Answer a) StudentID_index
b) ID
Answer:c c) StudentID
Explanation:The information can be referred d) Student
and obtained . View Answer

Answer:d
Database Questions and Explanation:The statement creates an index
Answers – SQL Data Types named studentID index on the attribute ID of
and Schemas the relation student.

This set of Database Questions & Answers 4. Which of the following is used to store movie
focuses on “SQL Data Types and Schemas” and image files ?
a) Clob
1. Dates must be specified in the format b) Blob
a) mm/dd/yy c) Binary
d) Image c) Check(value >= 29000.00);
View Answer d) Check(value)
View Answer
Answer:b
Explanation:SQL therefore provides large-object Answer:c
data types for character data (clob) and binary Explanation:Check(value ‘condition’) is the
data (blob). The letters “lob” in these data types syntax.
stand for “Large OBject.” .
8. Which of the following closely resembles
5. The user defined data type can be created Create view ?
using a) Create table . . .like
a) Create datatype b) Create table . . . as
b) Create data c) With data
c) Create definetype d) Create view as
d) Create type View Answer
View Answer
Answer:b
Answer:d Explanation:The ‘create table . . . as’ statement
Explanation:The create type clause can be used closely resembles the create view statement
to define new types.Syntax : create type Dollars and both are defined by using queries.The main
as numeric(12,2) final; . difference is that the contents of the table are
set when the table is created, whereas the
6. Values of one type can be converted to contents of a view always reflect the current
another domain using which of the following ? query result.
a) Cast
b) Drop type 9. In contemporary databases the top level of
c) Alter type the hierarchy consists of ______, each of which
d) Convert can contain _____.
View Answer a) Catalogs, schemas
b) Schemas, catalogs
Answer:a c) Environment, schemas
Explanation: Example of cast :cast d) Schemas, Environment
(department.budget to numeric(12,2)). SQL View Answer
provides drop type and alter type clauses to
drop or modify types that have been created Answer:a
earlier. Explanation:None.

7. Create domain YearlySalary numeric(8,2) 10. Which of the following statements creates a
constraint salary value test __________; new table temp instructor that has the same
In order to ensure that an instructor’s salary schema as instructor.
domain allows only values greater than a a) create table temp_instructor;
specified value use: b) Create table temp_instructor like instructor;
a) Value>=30000.00 c) Create Table as temp_instructor;
b) Not null;
d) Create table like temp_instructor; 3. Which of the following is used to provide
View Answer privilege to only a particular attribute ?
a) Grant select on employee to Amit
Answer:b b) Grant update(budget) on department to Raj
Explanation:None. c) Grant update(budget,salary,Rate) on
department to Raj
Database Questions and d) Grant delete to Amit
View Answer
Answers – Authorizations
Answer:b
This set of Database Questions & Answers
Explanation:This grant statement gives user Raj
focuses on “Authorizations”
update authorization on the budget attribute of
1. The database administrator who authorizes the department relation.
all the new users, modifies database and takes
4. Which of the following statement is used to
grants privilege is
remove the privilege from the user Amir ?
a) Super user
a) Remove update on department from Amir
b) Administrator
b) Revoke update on employee from Amir
c) Operator of operating system
c) Delete select on department from Raj
d) All of the mentioned
d) Grant update on employee from Amir
View Answer
View Answer
Answer:d
Answer:b
Explanation:The authorizations provided by the
Explanation:revoke on from ;
administrator to the user is privilege.
5. Which of the following is used to provide
2. Which of the following is a basic form of
delete authorization to instructor ?
grant statement ?
a) Create role instructor ;
a) Grant ‘privilege list’
grant delete to instructor;
on ‘relation name or view name’
b) Create role instructor;
to ‘user/role list’;
grant select on takes
b) Grant ‘privilege list’
to instructor;
on ‘user/role list’
c) Create role instructor;
to ‘relation name or view name’;
grant delete on takes
c) Grant ‘privilege list’
to instructor;
to ‘user/role list’
d) All of the mentioned
d) Grant ‘privilege list’
View Answer
on ‘relation name or view name’
on ‘user/role list’; Answer:c
View Answer Explanation:The role is first created and the
authorization is given on relation takes to the
Answer:a
role.
Explanation:The privilege list allows the
granting of several privileges in one command .
6. Which of the following is true regarding views authorization is revoked .
? View Answer
a) The user who creates a view cannot be given
update authorization on a view without having Answer:c
update authorization on the relations used to Explanation:A user has an authorization if and
define the view. only if there is a path from the root of the
b) The user who creates a view cannot be given authorization graph down to the node
update authorization on a view without having representing the user.
update authorization on the relations used to 9. Which of the following is used to avoid
define the view. cascading of authorizations from the user ?
c) If a user creates a view on which no a) Granted by current role
authorization can be granted, the system will b) Revoke select on department from Amit,
allow the view creation request. Satoshi restrict;
d) A user who creates a view receives all c) Revoke grant option for select on department
privileges on that view. from Amit;
View Answer d) Revoke select on department from Amit,
Answer:c Satoshi cascade;
Explanation:A user who creates a view does not View Answer
necessarily receive all privileges on that view. Answer:b
7. If we wish to grant a privilege and to allow Explanation:The revoke statement may specify
the recipient to pass the privilege on to other restrict in order to prevent cascading
users, we append the __________ clause to the revocation.The keyword cascade can be used
appropriate grant command. instead of restrict to indicate that revocation
a) With grant should cascade.
b) Grant user 10. The granting and revoking of roles by the
c) Grant pass privelege user may cause some confusions when that
d) With grant option user role is revoked .To overcome the above
View Answer situation
Answer:d a) The privilege must be granted only by roles
Explanation:None. b) The privilege is granted by roles and users
c) The user role cannot be removed once given
8. In authorization graph if DBA provides d) By restricting the user access to the roles
authorization to u1 which inturn gives to u2 View Answer
which of the following is correct ?
a) If DBA revokes authorization from u1 then u2 Answer:a
authorization is also revoked . Explanation:The current role associated with a
b) If u1 revokes authorization from u2 then u2 session can be set by executing set role role
authorization is revoked . name. The specified role must have been
c) Both a and b granted to the user, else the set role statement
d) If u2 revokes authorization then u1 fails.
Database Questions and 3. DriverManager.getConnection(_______ ,
______ , ______)
Answers – Access SQL From What are the two parameters that are
a Programming Language included ?
a) URL or machine name where server runs,
This set of Database Questions & Answers
Password, User ID
focuses on “Accessing SQL From a Programming
b) URL or machine name where server runs,
Language”
User ID, Password
1. Which of the following is used to access the c) User ID, Password, URL or machine name
database server at time of executing the where server runs
program and get the data from the server d) Password, URL or machine name where
accordingly ? server runs, User ID
a) Embedded SQL View Answer
b) Dynamic SQL
Answer:b
c) SQL declarations
Explanation:The database must be opened first
d) SQL data analysis
in order to perform any operations for which
View Answer
this get connection method is used .
Answer:b
4. Which of the following invokes functions in
Explanation:Embedded SQL, the SQL statements
sql ?
are identified at compile time using a
a) Prepared Statements
preprocessor. The preprocessor submits the
b) Connection statement
SQL statements to the database system for
c) Callable statements
precompilation and optimization; then it
d) All of the mentioned
replaces the SQL statements in the application
View Answer
program with appropriate code and function
calls before invoking the programming-language 5. Which of the following function is used to
compiler. find the column count of the particular resultset
?
2. Which of the following header must be
a) getMetaData()
included in java program to establish database
b) Metadata()
connectivity using JDBC ?
c) getColumn()
a) Import java.sql.*;
d) get Count()
b) Import java.sql.odbc.jdbc.*;
View Answer
c) Import java.jdbc.*;
d) Import java.sql.jdbc.*; Answer:a
View Answer Explanation:The interface ResultSet
has a method, getMetaData(), that returns a
Answer:a
ResultSetMetaData object that contains
Explanation:The Java program must import
metadata about the result set.
java.sql.*, which contains the interface
ResultSetMetaData, in turn, has methods to
definitions for the functionality provided by
find metadata information, such as the number
JDBC.
of columns in the result, the name of a specified 9. The update statement can be executed in
column, or the type of a specified column. host language using
a) EXEC SQL update c;
6. Which of the following is a following b) EXEC SQL update c into :si, :sn;
statement is a prepared statements ? c) EXEC SQL
a) Insert into department values(?,?,?) update instructor
b) Insert into department values(x,x,x). set salary = salary + 100
c) SQLSetConnectOption(conn, SQL where current of c;
AUTOCOMMIT, 0) d) EXEC SQL update END-SQL
d) SQLTransact(conn, SQL ROLLBACK) View Answer
View Answer
Answer:c
Answer:a Explanation:The SQL can be terminated by ; to
Explanation:? is used as a placeholder whose terminate the sentence.
value can be provided later.
10. Which of the following is used to access
7. Which of the following is used as the large objects from a database ?
embedded SQL in COBOL ? a) setBlob()
a) EXEC SQL ; b) getBlob()
b) EXEC SQL END-EXEC c) getClob()
c) EXEC SQL d) All of the mentioned
d) EXEC SQL END EXEC; View Answer
View Answer
Answer:d
Answer:b Explanation:None.
Explanation:EXEC SQL ; is normally in C.

8. Which of the following is used to distinguish Database Questions and


the variables in SQL from the host language
Answers – Functions and
variables ?
a) . Procedures
b) - This set of Database Questions & Answers
c) : focuses on “Functions and Procedures”
d) ,
View Answer 1.

Answer:b Create function dept count(dept_name


Explanation:EXEC SQL varchar(20))
declare c cursor for
begin
select ID, name
from student declare d count integer;
where tot cred > :credit amount;.
select count(*) into d count
from instructor b) Get and put
c) Out and In
where instructor.dept_name= dept_name d) In and out
return d count; View Answer

end Answer:d
Explanation:Create procedure dept count
Find the error in the the above statement . proc(in dept name varchar(20), out d count
a) Return type missing integer).Here in and out refers to input and
b) Dept_name is mismatched result of procedure.
c) Reference relation is not mentioned
d) All of the mentioned 4.
View Answer Create procedure dept_count proc(in dept
Answer:a name varchar(20),
Explanation:Return integer should be given out d count integer)
after create function for this particular
function . begin

2. For the function created in Question 1 ,which select count(*) into d count
of the following is a proper select statement ?
a) Select dept name, budget from instructor
from instructor where instructor.dept name= dept count
where dept count() > 12; proc.dept name
b) Select dept name, budget
from instructor end
where dept count(dept name) > 12;
Which of the following is used to call the
c) Select dept name, budget
procedure given above ?
where dept count(dept name) > 12;
a) Declare d_count integer;
d) Select dept name, budget
b) Declare d_count integer;
from instructor
call dept_count proc(’Physics’, d_count);
where dept count(budget) > 12;
c) Declare d_count integer;
View Answer
call dept_count proc(’Physics’);
Answer:b d) Declare d_count;
Explanation:The count of the dept_name must call dept_count proc(’Physics’, d_count);
be checked for the displaying from instructor View Answer
relation.
Answer:b
3. Which of he following is used to input the Explanation:Here the ‘Physics’ is in variable and
entry and give the result in a variable in a d_count is out variable.
procedure ?
5. The format for compound statement is
a) Put and get
a) Begin ……. end
b) Begin atomic……. end then statement or compound statement
c) Begin ……. repeat elif boolean expression
d) Both a and b then statement or compound statement
View Answer else statement or compound statement
end if
Answer:d d) If boolean expression
Explanation:A compound statement is of the then statement or compound statement
form begin . . . end, and it may contain multiple else
SQL statements between the begin and the statement or compound statement
end.A compound statement of the form begin else statement or compound statement
atomic . . . end ensures that all the statements end if
contained within it are executed as a single View Answer
transaction.
Answer:a
6. Repeat Explanation:The conditional statements
sequence of statements; supported by SQL include if-then-else
__________________ statements by using this syntax.elif and elsif are
end repeat not allowed.
Fill in the correct option :
a) While Condition 8. A stored procedure in SQL is a___________.
b) Until variable a) Block of functions
c) Until boolean expression b) Group of Transact-SQL statements compiled
d) Until 0 into a single execution plan.
View Answer c) Group of distinct SQL statements.
d) None of mentioned
Answer:c View Answer
Explanation:None.
Answer:b
7. Which of the following is the correct format Explanation:If it a atomic statement then the
for if statement ? statements are in single transaction.
a) If boolean expression
then statement or compound statement 9. Temporary stored procedures are stored in
elseif boolean expression _________ database.
then statement or compound statement a) Master
else statement or compound statement b) Model
end if c) User specific
b) If boolean expression d) Tempdb
then statement or compound statement View Answer
elsif boolean expression
then statement or compound statement Answer:d
else statement or compound statement Explanation:None.
end if 10. Declare out of classroom seats condition
c) If boolean expression declare exit handler for out of classroom seats
begin Answer:c
sequence of statements Explanation:The triggers run after an insert,
end update or delete on a table. They are not
The above statements are used for supported for views.
a) Calling procedures
b) Handling Exception 3. The CREATE TRIGGER statement is used to
c) Handling procedures create the trigger. THE _____ clause specifies
d) All of the mentioned the table name on which the trigger is to be
View Answer attached. The ______ specifies that this is an
AFTER INSERT trigger.
Answer:b a) for insert, on
Explanation:The SQL procedural language also b) On, for insert
supports the signaling of exception conditions, c) For, insert
and declaring of handlers that can handle the d) Both a and c
exception, as in this code. View Answer

Answer:b
Database Questions and Explanation:The triggers run after an insert,
Answers – Triggers update or delete on a table. They are not
supported for views.
This set of Database Questions & Answers
focuses on “Triggers” 4. What are the after triggers ?
a) Triggers generated after a particular
1. A __________ is a special kind of a store operation
procedure that executes in response to certain b) These triggers run after an insert, update or
action on the table like insertion, deletion or delete on a table
updation of data. c) These triggers run after an insert, views,
a) Procedures update or delete on a table
b) Triggers d) Both b and c
c) Functions View Answer
d) None of the mentioned
View Answer Answer:b
Explanation:AFTER TRIGGERS can be classified
Answer:b further into three types as: AFTER INSERT
Explanation:Triggers are automatically Trigger, AFTER UPDATE Trigger. ,AFTER DELETE
generated when a particular operation takes Trigger.
place.
5. The variables in the triggers are declared
2. Trigger are supported in using
a) Delete a) -
b) Update b) @
c) Views c) /
d) All of the mentioned
View Answer
d) /@ c) Ought to be
View Answer d) Always
View Answer
Answer:b
Explanation:Example : declare @empid int; Answer:a
where empid is the variable. Explanation:Triggers can be manipulated.

6. The default extension for an Oracle SQL*Plus 10. Which prefixes are available to Oracle
file is: triggers?
a) .txt a) : new only
b) .pls b) : old only
c) .ora c) Both :new and : old
d) .sql d) Neither :new nor : old
View Answer View Answer

Answer:d Answer:c
Explanation:Example :None. Explanation:None.

7. Which of the following is NOT an Oracle-


supported trigger? Database Questions and
a) BEFORE Answers – Recursive
b) DURING Queries and Aggregation
c) AFTER
d) INSTEAD OF
Features
View Answer This set of Database Questions & Answers
focuses on “Recursive Queries and Aggregation
Answer:b
Features”
Explanation:Example uring trigger is not
possible in any database. 1. Any recursive view must be defined as the
union of two subqueries: a _______ query that
8. What are the different in triggers ?
is nonrecursive and a __________ query.
a) Define, Create
a) Base, recursive
b) Drop, Comment
b) Recursive, Base
c) Insert, Update, Delete
c) Base, Redundant
d) All of the mentioned
d) View, Base
View Answer
View Answer
Answer:c
Answer:a
Explanation:Triggers are not possible for
Explanation:First compute the base query and
create,drop.
add all the resultant tuples to the recursively
9. Triggers ________ enabled or disabled defined view relation.
a) Can be
2. Ranking of queries is done by which of the
b) Cannot be
following ?
a) Group by should use
b) Order by a) Limit 10
c) Having b) Upto 10
d) Both a and b c) Only 10
View Answer d) Max 10
View Answer
Answer:b
Explanation:Order by clause arranges the values Answer:a
in ascending or descending order where default Explanation:However, the limit clause does not
is ascending order . support partitioning, so we cannot get the top n
within each partition without performing
3. In rank() function if one value is shared by ranking; further, if more than one student gets
two tuples then the same GPA, it is possible that one is included
a) The rank order continues as counting in the top 10, while another is excluded.
numbers
b) The rank order continues by leaving one rank 6. If there are n tuples in the partition and the
in the middle rank of the tuple is r , then its ________ is
c) The user specifies the order defined as (r −1)/(n−1) .
d) The order does not change a) Ntil()
View Answer b) Cum_rank
c) Percent_rank
Answer:b d) rank()
Explanation:Example . rank() over (order by View Answer
(GPA) desc).
Answer:c
4. The __________ function that does not Explanation:Percent rank of a tuple gives the
create gaps in the ordering. rank of the tuple as a fraction.
a) Intense_rank()
b) Continue_rank() 7. Inorder to simplify the null value confusion in
c) Default_rank() the rank function we can specify
d) Dense_rank() a) Not Null
View Answer b) Nulls last
c) Nulls first
Answer:d d) Either b or c
Explanation:For dense_rank() the tuples with View Answer
the second highest value all get rank 2, and
tuples with the third highest value get rank 3, Answer:d
and so on . Explanation:select ID, rank () over (order by GPA
desc nulls last) as s rank from student grades;.
5. Select ID, GPA
from student grades 8. Suppose we are given a view tot credits (year,
order by GPA num credits) giving the total number of credits
____________; taken by students in each year.The query that
Inorder to give only 10 rank on the whole we computes averages over the 3 preceding tuples
in the specified sort order is Answer:b
a) Select year, avg(num credits) Explanation:None.
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) Database Questions and
as avg total credits Answers – OLAP
from tot credits;
c) Both a and b This set of Database Questions & Answers
d) Either a or b focuses on “OLAP”
View Answer 1. OLAP stands for
Answer:a a) Online analytical processing
Explanation:Suppose that instead of going back b) Online analysis processing
a fixed number of tuples, we want the window c) Online transaction processing
to consist of all prior years we use rows d) Online aggregate processing
unbounded preceding. View Answer

9. The functions which construct histograms Answer:a


and use buckets for ranking is Explanation:OLAP is the manipulation of
a) Rank() information to support decision making .
b) Newtil() 2. Data that can be modeled as dimension
c) Ntil() attributes and measure attributes are called
d) None of the mentioned _______ data.
View Answer a) Multidimensional
Answer:c b) Singledimensional
Explanation:For each tuple, ntile(n) then gives c) Measured
the number of the bucket in which it is placed, d) Dimensional
with bucket numbers starting with 1. View Answer

10. The command ________________ such Answer:a


tables are available only within the transaction Explanation:Given a relation used for data
executing the query, and are dropped when the analysis, we can identify some of its attributes
transaction finishes. as measure attributes, since they measure some
a) Create table value, and can be aggregated upon.Dimension
b) Create temporary table attribute define the dimensions on which
c) Create view measure attributes, and summaries of measure
d) Create label view attributes, are viewed.
View Answer 3. The generalization of cross-tab which is
represented visually is ____________ which is
also called as data cube. d) All of the mentioned
a) Two dimensional cube View Answer
b) Multidimensional cube
c) N-dimensional cube Answer:a
d) Cuboid Explanation:pivot (sum(quantity) for color in
View Answer (’dark’,’pastel’,’white’)) .

Answer:a 7. { (item name, color, clothes size), (item name,


Explanation:Each cell in the cube is identified color), (item name, clothes size), (color, clothes
for the values for the three dimensional size), (item name), (color), (clothes size), () }
attributes. This can be achieved by using which of the
following ?
4. The process of viewing the cross-tab (Single a) group by rollup
dimensional) with a fixed value of one attribute b) group by cubic
is c) group by
a) Slicing d) None of the mentioned
b) Dicing View Answer
c) Pivoting
d) Both a and b Answer:d
View Answer Explanation:’Group by cube’ is used .

Answer:d 8. What do data warehouses support?


Explanation:For eg., The item name and colour a) OLAP
is viewed for a fixed size. b) OLTP
c) OLAP and OLTP
5. The operation of moving from finer- d) Operational databases
granularity data to a coarser granularity (by View Answer
means of aggregation) is called a ________.
a) Rollup Answer:a
b) Drill down Explanation:None .
c) Dicing 9. Select item name, color, clothes size,
d) Pivoting sum(quantity)
View Answer from sales
Answer:a group by rollup(item name, color, clothes size);
Explanation:The opposite operation—that of How many grouping is possible in this rollup?
moving fromcoarser-granularity data to finer- a) 8
granularity data—is called a drill down. b) 4
c) 2
6. In SQL the cross-tabs are created using d) 1
a) Slice View Answer
b) Dice
c) Pivot
Answer:b c) Assignment
Explanation:{ (item name, color, clothes size), d) None of the mentioned
(item name, color), (item name), () } . View Answer

10. Which one of the following is the right Answer:d


syntax for DECODE ? Explanation:The fundamental operations are
a) DECODE (search, expression, result [, search, select, project, union, set difference, Cartesian
result]… [, default]) product, and rename.
b) DECODE (expression, result [, search, result]…
[, default], search) 3. Which of the following is used to denote the
c) DECODE (search, result [, search, result]… [, selection operation in relational algebra ?
default], expression) a) Pi (Greek)
d) DECODE (expression, search, result [, search, b) Sigma (Greek)
result]… [, default]) c) Lambda (Greek)
View Answer d) Omega (Greek)
View Answer
Answer:d
Explanation:None . Answer:b
Explanation:The select operation selects tuples
that satisfy a given predicate.
Database Questions and
4. For select operation the ________ appear in
Answers – Relational Algebra
the subscript and the ___________ argument
This set of Database Questions & Answers appears in the paranthesis after the sigma.
focuses on “Relational Algebra” a) Predicates, relation
b) Relation, Predicates
1. Relational Algebra is a __________ query c) Operation, Predicates
language that takes two relation as input and d) Relation, Operation
produces another relation as output of the View Answer
query.
a) Relational Answer:a
b) Structural Explanation:None.
c) Procedural
5. The ___________ operation, denoted by −,
d) Fundamental
allows us to find tuples that are in one relation
View Answer
but are not in another.
Answer:c a) Union
Explanation:This language has fundamental and b) Set-difference
other operations which are used on relations . c) Difference
d) Intersection
2. Which of the following is a fundamental View Answer
operation in relational algebra ?
a) Set intersection
b) Natural join
Answer:b Answer:d
Explanation:The expression r − s produces a Explanation:The FULL OUTER JOIN keyword
relation containing those tuples in r but not in s. combines the result of both LEFT and RIGHT
joins.
6. Which is a unary operation:
a) Selection operation 10. The assignment operator is denoted by
b) Primitive operation a) ->
c) Projection operation b) <-
d) Generalized selection c) =
View Answer d) ==
View Answer
Answer:d
Explanation:Generalization Selection takes only Answer:b
one argument for operation. Explanation:the result of the expression to the
right of the ← is assigned to the relation
7. Which is a join condition contains an equality variable on the left of the ←.
operator:
a) Equijoins
b) Cartesian Database Questions and
c) Natural Answers – Tuple Relational
d) Left Calculus and Domain
View Answer
Relational Calculus
Answer:a
This set of Database Questions & Answers
Explanation:None.
focuses on “Tuple Relational Calculus and
8. In precedence of set operators the Domain Relational Calculus”
expression is evaluated from
1. Find the ID, name, dept name, salary for
a) Left to left
instructors whose salary is greater than $80,000
b) Left to right
.
c) Right to left
a) {t | t ε instructor ∧ t[salary] > 80000}
d) From user specification
b) Э t ∈ r (Q(t))
View Answer
c) {t | Э s ε instructor (t[ID] = s[ID]∧ s[salary] >
Answer:b 80000)}
Explanation:The expression is evaluated from d) Only a and b
left to right according to the precedence. View Answer

9. Which of the following is not outer join ? Answer:a


a) Left outer join Explanation:This expression is in tuple relational
b) Right outer join format.
c) Full outer join
2. A query in the tuple relational calculus is
d) All of the mentioned
expressed as:
View Answer
a) {t | P() | t} Answer:c
b) {P(t) | t } Explanation:The query ¬P negates the value of P
c) {t | P(t)} .
d) All of the mentioned
View Answer 5. “Find all students who have taken all courses
offered in the Biology department.” The
Answer:c expressions that matches this sentence is :
Explanation:The tuple relational calculus, is a a) Э t ε r (Q(t))
nonprocedural query language. It describes the b) ∀ t ε r (Q(t))
desired information without giving a specific c) ¬ t ε r (Q(t))
procedure for obtaining that information. d) ~ t ε r (Q(t))
View Answer
3. {t | Э s ε instructor (t[name] = s[name]
∧ Э u ε department (u[dept name] = s[dept Answer:b
name] Explanation:∀ is used denote “for all” in SQL.
∧ u[building] = “Watson”))}
Which of the following best describes the query 6. Which of the following is the comparison
? operator in tuple relational calculus
a) Finds the names of all instructors whose a) ⇒
department is in the Watson building. b) =
b) Finds the names of all department is in the c) ε
Watson building. d) All of the mentioned
c) Finds the name of the dapartment whose View Answer
instructor and building is Watson. Answer:b
d) Returns the building name of all the Explanation:The comparison operators are (<, ≤,
departments. =, =, >, ≥).
View Answer
7. An expression in the domain relational
Answer:a calculus is of the form
Explanation:This query has two “there exists” a) {P(x1, x2, . . . , xn) | < x1, x2, . . . , xn > }
clauses in our tuple-relational-calculus b) {x1, x2, . . . , xn | < x1, x2, . . . , xn > }
expression, connected by and (∧). c) { x1, x2, . . . , xn | x1, x2, . . . , xn}
4. Which of the following symbol is used in the d) {< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)}
place of except ? View Answer
a) ^ Answer:d
b) V Explanation:Here x1, x2, . . . , xn represent
c) ¬ domain variables. P represents a formula
d) ~ composed of atoms, as was the case in the
View Answer tuple relational calculus.

8. Find the names of all instructors in the


Physics department together with the course id
of all courses they teach: This set of Database Questions & Answers
a) {< c > | Э s (< c, a, s, y, b, r, t >ε section focuses on “The Entity-Relationship Model”
∧s = “Fall” ∧ y = “2009”
∨Эu (< c, a, s, y, b, r, t >ε section 1. An ________ is a set of entities of the same
∧s = “Spring” ∧ y = “2010” type that share the same properties, or
b) {< n, c > | Э i, a (< i, c, a, s, y > ε teaches attributes .
∧ Э d, s (< i, n, d, s > ε instructor ∧ d = a) Entity set
“Physics”))} b) Attribute set
c) {< n > | Э i, d, s (< i, n, d, s > ε instructor ∧ s > c) Relation set
80000)} d) Entity model
d) {< i, n, d, s > | < i, n, d, s > ε instructor ∧ s > View Answer
80000} Answer:a
View Answer Explanation:An entity is a “thing” or “object” in
Answer:b the real world that is distinguishable from all
Explanation:None. other objects.

9. In domain relaional calculus “there exist” can 2. Entity is a


be expressed as a) Object of relation
a) (P1(x)) b) Present working model
b) (P1(x)) Э x c) Thing in real world
c) V x (P1(x)) d) Model of relation
d) Э x (P1(x)) View Answer
View Answer Answer:c
Answer:d Explanation:For example, each person in a
Explanation:Э is used to denote “some” values university is an entity.
in relational calculus. 3. The descriptive property possessed by each
10. A set of possible data values is called entity set is _________ .
a) Attribute a) Entity
b) Degree b) Attribute
c) Tuple c) Relation
d) Domain d) Model
View Answer View Answer

Answer:d Answer:b
Explanation:None. Explanation:Possible attributes of the instructor
entity set are ID, name, dept name, and salary.

Database Questions and 4. The function that an entity plays in a


relationship is called that entity’s
Answers – The Entity-
_____________.
Relationship Model a) Participation
b) Position Answer:c
c) Role Explanation:NULL always represents that the
d) Instance value is not present.
View Answer
8. Which of the following can be a multivalued
Answer:c attribute ?
Explanation:A relationship is an association a) Phone_number
among several entities. b) Name
c) Date_of_birth
5. The attribute name could be structured as a d) All of the mentioned
attribute consisting of first name, middle initial, View Answer
and last name . This type of attribute is called
a) Simple attribute 9. Which of the following is a single valued
b) Composite attribute attribute
c) Multivalued attribute a) Register_number
d) Derived attribute b) Address
View Answer c) SUBJECT_TAKEN
d) Reference
Answer:b View Answer
Explanation:Composite attributes can be
divided into subparts (that is, other attributes). Answer:a
Explanation:None.
6. The attribute AGE is calculated from
DATE_OF_BIRTH . The attribute AGE is 10. In a relation between the entities the type
a) Single valued and condition of the relation should be
b) Multi valued specified . That is called as______attribute
c) Composite a) Desciptive
d) Derived b) Derived
View Answer c) Recursive
d) Relative
Answer:d View Answer
Explanation:The value for this type of attribute
can be derived from the values of other related Answer:a
attributes or entities. Explanation:Consider the entity sets student
and section, which participate in a relationship
7. Not applicable condition can be represented set takes. We may wish to store a descriptive
in relation entry as attribute grade with the relationship to record
a) NA the grade that a student got in the class.
b) 0
c) NULL
d) Blank Space
View Answer

You might also like