Questions and Answers On The Relational Model
Questions and Answers On The Relational Model
Questions and Answers On The Relational Model
The following sections contains various questions on dealing with the concept of
Relational Model. These include relational and database schema, keys and
relational query operators.
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
Answer: b
Explanation: Data Definition language is the language which performs all the
operation in defining structure of relation.
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
Answer: a
Explanation: DML performs the change in the values of the relation.
CREATE TABLE employee (name VARCHAR, id INTEGER)
What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
Answer: b
Explanation: Data Definition language is the language which performs all the
operation in defining structure of relation.
answer: a
Explanation: Select operation just shows the required fields of the relation. So it
forms a DML.
he basic data type char(n) is a _____ length character string and varchar(n) is
_____ length character.
a)Fixed,equal
b)Equal,variable
c)Fixed,variable
d) Variable, equal
answer:c
Explanation: Varchar changes its length accordingly whereas char has a specific
length which has to be filled by either letters or spaces.
Answer: a
Explanation: Varchar changes its length accordingly whereas char has a specific
length which has to be filled by either letters or spaces.
Answer: d
Explanation: Drop table deletes the whole structure of the relation .purge
removes the table which cannot be obtained again.
Answer: b
Explanation: Delete command removes the entries in the table.
INSERT INTO instructor VALUES (10211, ’Smith’, ’Biology’,
66000);
What type of statement is this?
a)Query
b)DML
c)Relational
d) DDL
Answer: b
Explanation: The values are manipulated. So it is a DML.
Answer: a
Explanation: Integrity constraint has to be maintained in the entries of the
relation.
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
Answer: c
Explanation: The field to be displayed is included in select and the table is
included in the from clause.
Here which of the following displays the unique values of the column?
Answer: c
Explanation: Distinct keyword selects only the entries that are unique.
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
Answer: a
Explanation: Where selects the rows on a particular condition. From gives the
relation which involves the operation.
The query given below will not give an error. Which one of the following has to
be replaced to get the desired output?
Answer: c
Explanation: Where selects the rows on a particular condition. From gives the
relation which involves the operation. Since Instructor is a relation it has to have
from clause.
The ________ clause is used to list the attributes desired in the result of a
query.
a)Where
b)Select
c)From
d) Distinct
Answer: b
Explanation: None
Answer: b
Explanation: Join clause joins two tables by matching the common column.
Answer: d
Explanation: Here * is used to select all the fields of the relation.
Employee_id Name
1001 Annie
1009 Ross
1018 Zeith
This is Employee table.
Which of the following employee_id will be displayed for the given query?
Answer: d
Explanation: Greater than symbol does not include the given value unlike >=.
Answer: d
Explanation: This query do not have from clause which specifies the relation
from which the values has to be selected.
Answer: b
Explanation: Value keyword has to be used to insert the values into the table.
Answer: c
Explanation: As keyword is used to rename.
Answer: c
Explanation: For any string operations single quoted(‘) must be used to enclose.
SELECT emp_name
FROM department
WHERE dept_name LIKE ’ _____ Computer Science’;
Which one of the following has to be added into the blank to select the
dept_name which has Computer Science as its ending string?
a)%
b)_
c)||
d) $
Answer: a
Explanation: The % character matches any substring.
Answer: b
Explanation: None.
SELECT name
FROM instructor
WHERE dept name = ’Physics’
ORDER BY name;
By default, the order by clause lists items in ______ order.
a)Descending
b)Any
c)Same
d) Ascending
Answer: d
Explanation: Specification of descending order is essential but it not for
ascending.
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
SELECT name
FROM instructor
WHERE salary <= 100000 AND salary >= 90000;
This query can be replaced by which of the following ?
a)
SELECT name
FROM instructor
WHERE salary BETWEEN 90000 AND 100000;
b)
SELECT name
FROM employee
WHERE salary <= 90000 AND salary>=100000;
c)
SELECT name
FROM employee
WHERE salary BETWEEN 90000 AND 100000;
d)
SELECT name
FROM instructor
WHERE salary BETWEEN 100000 AND 90000;
Answer: 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.
SELECT instructor.*
FROM instructor, teaches
WHERE instructor.ID= teaches.ID;
This query does which of the following operation?
a)All attributes of instructor and teaches are selected
b)All attributes of instructor are selected on the given condition
c)All attributes of teaches are selected on given condition
d) Only the some attributes from instructed and teaches are selected
Answer: b
Explanation: The asterisk symbol “ * ” can be usedin the select clause to denote
“all attributes.”
In SQL the spaces at the end of the string are removed by _______ function.
a)Upper
b)String
c)Trim
d) Lower
Answer:c
Explanation: The syntax of trim is Trim(s); where s-string.
Answer:c
Explanation: || is the concatenation operator.
This set of Database Multiple Choice Questions & Answers (MCQs) focuses on
“Set Operations”.
Answer:b
Explanation: Union operator combines the relations.
Answer:b
Explanation: Intersection operator ignores unique tuples and takes only common
ones.
Answer:d
Explanation: None.
Answer:a
Explanation: Union all will combine all the tuples including duplicates.
(SELECT course id
FROM SECTION
WHERE semester = ’Fall’ AND YEAR= 2009)
EXCEPT
(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010);
This query displays
a)Only tuples from second part
b)Only tuples from the first part which has the tuples from second part
c)Tuples from both the parts
d) Tuples from first part which do not have second part
Answer: d
Explanation: Except keyword is used to ignore the values.
Answer:a
Explanation:% is used with like and _ is used to fill in the character.
Answer:b
Explanation: None.
Answer:b
Explanation: It is optional to give the inner keyword with the join as it is default.
Answer:a
Explanation: Like predicate matches the string in the given pattern.
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
Answer:c
Explanation: None
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
Answer:c
Explanation: Null is used to represent the absence of a value.
The predicate in a where clause can involve Boolean operations such as and.
The result of true and unknown is_______ false and unknown is _____ while
unknown and unknown is _____
a)Unknown,unknown,false
b)True,false,unknown
c)True,unknown,unknown
d) Unknown, false, unknown
Answer:d
Explanation: None.
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
Answer:b
Explanation: Not null constraint removes the tpules of null values.
In an employee table to include the attributes whose value always have some
value which of the following constraint must be used?
a)Null
b)Not null
c)Unique
d) Distinct
Answer:b
Explanation: Not null constraint removes the tuples of null values.
Using the ______ clause retains only one copy of such identical tuples.
a)Null
b)Unique
c)Not null
d) Distinct
Answer:d
Explanation: Unique is a constraint.
Answer:c
Explanation: Not null constraint is specified which means sone value (can
include 0 also) should be given.
Answer:c
Explanation: Primary key must satisfy unique and not null condition for sure.
Answer:a
Explanation: The expression attempts to divide by a null value is erroneous in
sql.
The result of _____unknown is unknown.
a)Xor
b)Or
c)And
d) Not
Answer:d
Explanation: Since unknown does not hold any value the value cannot have a
reverse value.
Aggregate functions are functions that take a ___________ as input and return
a single value.
a)Collection of values
b)Single value
c)Aggregate value
d) Both Collection of values & Single value
Answer:a
Explanation: None.
SELECT __________
FROM instructor
WHERE dept name= ’Comp. Sci.’;
Which of the following should be used to find the mean of the salary ?
a)Mean(salary)
b)Avg(salary)
c)Sum(salary)
d) Count(salary)
Answer:b
Explanation: Avg() is used to find the mean of the values.
Answer:a
Explanation: Distinct keyword is used to select only unique items from the
relation.
All aggregate functions except _____ ignore null values in their input collection.
a)Count(attribute)
b)Count(*)
c)Avg
d) Sum
Answer:b
Explanation: * is used to select all values including null.
A Boolean data type that can take values true, false, and________
a)1
b)0
c)Null
d) Unknown
Answer:d
Explanation: Unknown values do not take null value but it is not known.
The ____ connective tests for set membership, where the set is a collection of
values produced by a select clause. The ____ connective tests for the absence
of set membership.
a)Or,in
b)Not in, in
c)In, not in
d) In, or
Answer:c
Explanation: In checks, if the query has the value but not in checks if it does not
have the value.
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.
The phrase “greater than at least one” is represented in SQL by _____
a)< all
b)< some
c)> all
d) > some
Answer:d
Explanation: >some takes atlest one value above it .
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)
Answer:a
Explanation: None.
We can test for the nonexistence of tuples in a subquery by using the _____
construct.
a)Not exist
b)Not exists
c)Exists
d) Exist
Answer: b
Explanation: Exists is used to check for the existence of tuples.
ELECT dept_name, ID, avg (salary)
FROM instructor
GROUP BY dept_name;
This statement IS erroneous because
a)Avg(salary) should not be selected
b)Dept_id should not be used in group by clause
c)Misplaced group by clause
d) Group by clause is not valid in this query
Answer:b
Explanation: Any attribute that is not present in the group by clause must appear
only inside an aggregate function if it appears in the select clause, otherwise the
query is treated as erroneous.
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
Answer:b
Explanation: The with clause provides away of defining a temporary relation
whose definition is available only to the query in which the with clause occurs.
Aggregate functions can be used in the select list or the_______clause of a
select statement or subquery. They cannot be used in a ______ clause.
a)Where, having
b)Having, where
c)Group by, having
d) Group by, where
Answer:b
Explanation: To include aggregate functions having clause must be included
after where.
Answer:b
Explanation: Eg : SELECT name, salary, avg salary
FROM instructor I1, lateral (SELECT avg(salary)
AS avg salary
FROM instructor I2
WHERE I2.dept name= I1.dept name);
Without the lateral clause, the subquery cannot access the correlation variable
I1 from the outer query.
Which of the following creates a temporary relation for the query on which it is
defined?
a)With
b)From
c)Where
d) Select
Answer:a
Explanation: The with clause provides a way of defining a temporary relation
whose definition is available only to the query in which the with clause occurs.
Answer:d
Explanation: With clause creates a temporary relation.
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.
Answer:c
Explanation: None.
Answer:c
Explanation: With is used to create temporary relation and its not an aggregate
function.
Answer:a
Explanation: EXISTS keyword checks for existance of a condition.
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
Answer:b
Explanation: None.
Answer:a
Explanation: Delete can delete from only one table at a time.
Answer:a
Explanation: Here P gives the condition for deleting specific rows.
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;
Answer:d
Explanation: Absence of condition deletes all rows.
Answer:b
Explanation: Using select statement in insert will include rows which are the
result of the selection.
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)
Answer:c
Explanation: The query must include building=watson condition to filter the
tuples.
UPDATE instructor
_____ salary= salary * 1.05;
Fill in with correct keyword to update the instructor relation.
a)Where
b)Set
c)In
d) Select
Answer:b
Explanation: Set is used to update the particular value.
_________ are useful in SQL update statements, where they can be used in the
set clause.
a)Multiple queries
b)Sub queries
c)Update
d) Scalar subqueries
Answer:d
Explanation: None.
Answer:c
Explanation: The case statements can add the order of updating tuples.
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
Answer:b
Explanation: None.
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
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.
Answer:a
Explanation: On gives the condition for the join expression.
Answer:c
Explanation: INNER JOIN: Returns all rows when there is at least one match in
BOTH tables.
SELECT *
FROM student JOIN takes USING (ID);
The above query is equivalent to
a)
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
Answer: a
Explanation: Join can be replaced by inner join.
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
Answer: c
Explanation: An outer join does not require each record in the two joined tables
to have a matching record..
How many tables may be included with a join?
a) One
b) Two
c) Three
d) All of the mentioned
Answer: d
Explanation: Join can combine multiple tables.
Which are the join types in join condition:
a) Cross join
b) Natural join
c) Join with USING clause
d) All of the mentioned
Answer: d
Explanation: There are totally four join types in SQL.
how many join types in join condition:
a) 2
b) 3
c) 4
d) 5
Answer: d
Explanation: Types are inner join, left outer join, right outer join, full join, cross
join.
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
Answer: b
Explanation: RIGHT OUTER JOIN: Return all rows from the right table and the
matched rows from the left table.
The operation which is not considered a basic operation of relational algebra is
a) Join
b) Selection
c) Union
d) Cross product
Answer: a
Explanation: None.
In SQL the statement select * from R, S is equivalent to
a) Select * from R natural join S
b) Select * from R cross join S
c) Select * from R union join S
d) Select * from R inner join S
Answer: b
Explanation: None.
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Views”.
Which of the following creates a virtual relation for storing the query?
a) Function
b) View
c) Procedure
d) None of the mentioned
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.
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”;
Answer: c
Explanation: <query expression> is any legal query expression. The view name
is represented by v.
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
Answer:c
Explanation: View names may appear in a query any place where a relation
name may appear.
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
Answer: d
Explanation: Once a transaction has executed commit work, its effects can no
longer be undone by rollback work.
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
Answer: c
Explanation: Once a transaction has executed commit work, its effects can no
longer be undone by rollback work.
In order to maintain the consistency during transactions, database provides
a) Commit
b) Atomic
c) Flashback
d) Retain
Answer: b
Explanation: By atomic, either all the effects of the transaction are reflected in
the database, or none are (after rollback).
Transaction processing is associated with everything below except
a) conforming an action or triggering a response
b) Producing detail summary or exception report
c) Recording a business activity
d) maintaining a data
Answer: a
Explanation: None.
A transaction completes its execution is said to be
a) Committed
b) Aborted
c) Rolled back
d) Failed
Answer: a
Explanation: A complete transaction always commits.
Which of the following is used to get back all the transactions back after
rollback?
a) Commit
b) Rollback
c) Flashback
d) Redo
Answer: c
Explanation: None.
. ______ will undo all statements up to commit?
a) Transaction
b) Flashback
c) Rollback
d) Abort
Answer: c
Explanation: Flashback will undo all the statements and Abort will terminate the
operation.
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “SQL Data Types and Schemas”.
Dates must be specified in the format
a) mm/dd/yy
b) yyyy/mm/dd
c) dd/mm/yy
d) yy/dd/mm
Answer: b
Explanation: yyyy/mm/dd is the default format in sql.
A ________ on an attribute of a relation is a data structure that allows the
database system to find those tuples in the relation that have a specified value
for that attribute efficiently, without scanning through all the tuples of the relation.
a) Index
b) Reference
c) Assertion
d) Timestamp
Answer: a
Explanation: Index is the reference to the tuples in a relation.
Create index studentID_index on student(ID);
Here which one denotes the relation for which index is created?
a)StudentID_index
b)ID
c)StudentID
d) Student
Answer: d
Explanation: The statement creates an index named studentID index on the
attribute ID of the relation student.
Answer:b
Explanation: SQL therefore provides large-object data types for character data
(clob) and binary data (blob). The letters “lob” in these data types stand for
“Large OBject”.
Values of one type can be converted to another domain using which of the
following?
a)Cast
b)Drop type
c)Alter type
d) Convert
Answer:a
Explanation: Example of cast :cast (department.budget to numeric(12,2)). SQL
provides drop type and alter type clauses to drop or modify types that have been
created earlier.
This set of Database Multiple Choice Questions & Answers (MCQs) focuses on
“Authorizations”.
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
Answer:d
Explanation: The authorizations provided by the administrator to the user is a
privilege.
Answer: c
Explanation: The first normal form is used to eliminate the duplicate information.
Which forms has a relation that possesses data about an individual entity:
a) 2NF
b) 3NF
c) 4NF
d) 5NF
Answer: c
Explanation: A Table is in 4NF if and only if, for every one of its non-trivial
multivalued dependencies X \twoheadrightarrow Y, X is a superkey—that is, X is
either a candidate key or a superset thereof.
Which forms are based on the concept of functional dependency:
a) 1NF
b) 2NF
c) 3NF
d) 4NF
Answer: c
Explanation: The table is in 3NF if every non-prime attribute of R is non-
transitively dependent (i.e. directly dependent) on every superkey of R.
This set of Database Multiple Choice Questions & Answers (MCQs)
focuses on “Physical Storage Media”.