0% found this document useful (0 votes)
13 views

DBMS & SQL

The document provides a comprehensive overview of Database Management Systems (DBMS) and SQL, covering definitions, functions, types, and key concepts such as primary keys, foreign keys, and data integrity. It includes multiple-choice questions and answers that test knowledge on DBMS features, operations, and commands. The document serves as an educational resource for understanding the fundamentals of databases and SQL usage.

Uploaded by

Abdul Nafe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

DBMS & SQL

The document provides a comprehensive overview of Database Management Systems (DBMS) and SQL, covering definitions, functions, types, and key concepts such as primary keys, foreign keys, and data integrity. It includes multiple-choice questions and answers that test knowledge on DBMS features, operations, and commands. The document serves as an educational resource for understanding the fundamentals of databases and SQL usage.

Uploaded by

Abdul Nafe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

DBMS & SQL

1. What is the full form of DBMS?


a) Data of Binary Management System
b) Database Management System
c) Database Management Service
d) Data Backup Management System
View Answer
Answer: b
Explanation: DBMS is abbreviated as Database Management System.
Database Management System stores the data and allows
authorized users to manipulate and modify the data.
2. What is a database?
a) Organized collection of information that cannot be accessed,
updated, and managed
b) Collection of data or information without organizing
c) Organized collection of data or information that can be accessed,
updated, and managed
d) Organized collection of data that cannot be updated
View Answer
Answer: c
Explanation: It is defined as an organized collection of data or
information for easy access, updating, and management in a
computer.
3. What is DBMS?
a) DBMS is a collection of queries
b) DBMS is a high-level language
c) DBMS is a programming language
d) DBMS stores, modifies and retrieves data
View Answer
Answer: d
Explanation: DBMS is nothing but a storehouse wherein the
authorized user can create a database to store, modify or retrieve
the organized data in the table. It can be modified or retrieved by
users who have access to DBMS only.
4. Who created the first DBMS?
a) Edgar Frank Codd
b) Charles Bachman
c) Charles Babbage
d) Sharon B. Codd
View Answer
Answer: b
Explanation: Charles Bachman along with his team invented the first
DBMS known as Integrated Data Store (IDS).
5. Which type of data can be stored in the database?
a) Image oriented data
b) Text, files containing data
c) Data in the form of audio or video
d) All of the above
View Answer
Answer: d
Explanation: The reason for creating the database management
system was to store large data and these data can be of any form
image, text, audio, or video files, etc. DBMS allows the users to store
and access the data of any format.
advertisement
6. In which of the following formats data is stored in the database
management system?
a) Image
b) Text
c) Table
d) Graph
View Answer
Answer: c
Explanation: The data is stored in a table format intended to manage
the storage of data and manipulate stored data to generate
information.
7. Which of the following is not a type of database?
a) Hierarchical
b) Network
c) Distributed
d) Decentralized
View Answer
Answer: d
Explanation: Different types are:
1) Centralized
2) Distributed
3) Relational
4) NoSQL
5) Cloud
6) Object-oriented
7) Hierarchical
8) Network
8. Which of the following is not an example of DBMS?
a) MySQL
b) Microsoft Acess
c) IBM DB2
d) Google
View Answer
Answer: d
Explanation: MySQL, Microsoft Access, IBM DB2 are database
management systems while Google is a search engine. MySQL is a
Linux-based database management system, Microsoft Access is a
tool that is a part of Microsoft Office used to store data, IBM DB2 is a
database management system developed by IBM. Google’s Bigtable
is the database that runs Google’s Internet search, Google Maps,
YouTube, Gmail, and other products.
9. Which of the following is not a feature of DBMS?
a) Minimum Duplication and Redundancy of Data
b) High Level of Security
c) Single-user Access only
d) Support ACID Property
View Answer
10. Which of the following is a feature of the database?
a) No-backup for the data stored
b) User interface provided
c) Lack of Authentication
d) Store data in multiple locations
View Answer
Answer: b
Explanation: The important features are:
1) Provides backup for the data stored by the user and the user can
retrieve the data whenever required.
2) Provides User-interface to access the data.
3) Only authorized users can access the stored data.
4) Data is stored in one central location but multiple authorized users
can access the data.
11. Which of the following is not a function of the database?
a) Managing stored data
b) Manipulating data
c) Security for stored data
d) Analysing code
View Answer
Answer: d
Explanation: It allows authorized users to update, store, manipulate,
or access data. Since data is stored in table format it is easy to access
the data and perform the required functions. It also removes
duplicate and redundant data.
12. Which of the following is a function of the DBMS?
a) Storing data
b) Providing multi-users access control
c) Data Integrity
d) All of the above
View Answer
Answer: d
Explanation: The purpose of creating DBMS was to store the data.
The data stored in the database management system can be can
accessed by multiple users if the access is provided. The data stored
will be accurate and complete hence providing data integrity.
13. Which of the following is a component of the DBMS?
a) Data
b) Data Languages
c) Data Manager
d) All of the above
View Answer
Answer: d
Explanation: The components of DBMS are as follows:
1) Hardware: Like a hard drive, monitor, etc.
2) Software: Provides a user interface
3) Data Manager: Manages operations of DBMS.
4) Data: The collection of information on the DB is known as data.
5) Data Languages: Languages like DDL, DML, DAL, and DCL allow to
perform operations like creating, modifying, storing, or retrieving
data.
14. Which of the following is known as a set of entities of the same
type that share same properties, or attributes?
a) Relation set
b) Tuples
c) Entity set
d) Entity Relation model
View Answer
Answer: c
Explanation: In the actual world, an entity is a distinct “thing” or
“object” from all other objects. For example: Each employee of an
organization is an entity.
15. What is information about data called?
a) Hyper data
b) Tera data
c) Meta data
d) Relations
View Answer
Answer: c
Explanation: Information about data is known as Metadata.
Metadata describes the data in detail by providing additional
information like type, length of the data, etc. Metadata helps the user
to understand the data.
16. What does an RDBMS consist of?
a) Collection of Records
b) Collection of Keys
c) Collection of Tables
d) Collection of Fields
View Answer
Answer: c
Explanation: It consists of a collection of tables i.e., the data is
organized in tabular format. The columns of the relation are known
as Fields and rows of the relation are known as fields. Constraints in
a relation are known as Keys.
17. The values appearing in given attributes of any tuple in the
referencing relation must likewise occur in specified attributes of at
least one tuple in the referenced relation, according to
_____________________ integrity constraint.
a) Referential
b) Primary
c) Referencing
d) Specific
View Answer
Answer: a
Explanation: Consider 2 relations r1 and r2. r1 may include among its
attributes the primary key of relation r2. This attribute is called a
foreign key from r1, referencing r2. The relation r1 is also called the
referencing relation of the foreign key dependency, and r2 is called
the referenced relation of the foreign key.
18. _____________ is a hardware component that is most important for
the operation of a database management system.
a) Microphone
b) High speed, large capacity disk to store data
c) High-resolution video display
d) Printer
View Answer
Answer: b
Explanation: Since all the data are stored in form of memory in the
disk, a high speed, and large-capacity disk is required for the
operation of the database management system.
19. The DBMS acts as an interface between ________________ and
________________ of an enterprise-class system.
a) Data and the DBMS
b) Application and SQL
c) Database application and the database
d) The user and the software
View Answer
Answer: c
Explanation: A database management system is an application that
acts as an interface between the user and the database. The user
interacts with the application to access data.
20. The ability to query data, as well as insert, delete, and alter
tuples, is offered by ____________
a) TCL (Transaction Control Language)
b) DCL (Data Control Language)
c) DDL (Data Definition Langauge)
d) DML (Data Manipulation Langauge)
View Answer
Answer: d
Explanation: A query is a request for data or information. Relational
Schema is the design and structure of the relation. DDL consists of
commands that help in modifying. DML performs the change in the
values of the relation.
21. ______________ is a set of one or more attributes taken collectively
to uniquely identify a record.
a) Primary Key
b) Foreign key
c) Super key
d) Candidate key
View Answer
Answer: c
Explanation: Foreign key creates a relationship between two
relations. Super key is the superset of all the keys in a relation. A
candidate key is used to identify tuples in a relation.
22. Which command is used to remove a relation from an SQL?
a) Drop table
b) Delete
c) Purge
d) Remove
View Answer
Answer: a
Explanation: Delete command is used to delete the existing record
from the table. The drop table deletes the whole structure of the
relation. Purge removes the table which cannot be obtained again.
23. Which of the following set should be associated with weak entity
set for weak entity to be meaningful?
a) Neighbour set
b) Strong entity set
c) Owner set
d) Identifying set
View Answer
Answer: d
Explanation: Every weak entity must be linked to an identifying
entity; in other words, the existence of the weak entity set is
contingent on the presence of the identifying entity set. The weak
entity set that the identifying entity set identifies is said to be owned
by the identifying entity set. Owner entity set is another name for it.
24. Which of the following command is correct to delete the values in
the relation teaches?
a) Delete from teaches;
b) Delete from teaches where Id =’Null’;
c) Remove table teaches;
d) Drop table teaches;
View Answer
Answer: a
Explanation: To delete the entries from the table Delete from table
command should be used.
25. Procedural language among the following is __________
a) Domain relational calculus
b) Tuple relational calculus
c) Relational algebra
d) Query language
View Answer
Answer: c
Explanation: Non-Procedural Languages are Domain relational
calculus and Tuple relational calculus. Relational algebra is a
procedural language that takes input in the form of relation and
output generated is also a relation.
26. _________________ operations do not preserve non-matched tuples.
a) Left outer join
b) Inner join
c) Natural join
d) Right outer join
View Answer
Answer: b
Explanation: Left outer join returns all the rows from the table that is
on the left side and matching rows on the right side of the join. Inner
join returns all rows when there is at least one match in BOTH tables.
Natural join returns the common columns from the tables being
joined. A right outer join returns all the rows from the table that is on
the right side and matching rows on the left side of the join.
27. Which forms have a relation that contains information about a
single entity?
a) 4NF
b) 2NF
c) 5NF
d) 3NF
View Answer
Answer: a
Explanation: If and only if, for each of its non-trivial multivalued
dependencies X \twoheadrightarrow Y, a table is in 4NF. X is a
superkey—that is, X is either a candidate key or a superset thereof.
28. The top level of the hierarchy consists of ______ each of which can
contain _____.
a) Schemas, Catalogs
b) Schemas, Environment
c) Environment, Schemas
d) Catalogs, Schemas
View Answer
Answer: d
Explanation: Schemas represent the logical configuration of the
DBMS. Catalogs consist of metadata of the objects and system
settings used.
29. _______ indicates the maximum number of entities that can be
involved in a relationship.
a) Greater Entity Count
b) Minimum cardinality
c) Maximum cardinality
d) ERD
View Answer
Answer: c
Explanation: The term cardinality refers to the uniqueness of data
values included in a single column (attribute) of a table in SQL
(Structured Query Language).
30. The user IDs can be added or removed using which of the
following fixed roles?
a) db_sysadmin
b) db_accessadmin
c) db_securityadmin
d) db_setupadmin
View Answer
Answer: b
Explanation: Along with security, as the name suggests the
db_accessadmin role also handles access. db_sysadmin refers to the
system administrator. db_securityadmin as the name suggests it
involves granting or declining permission to access the data ensuring
security.
31. Why the following statement is erroneous?

SELECT dept_name, ID, avg (salary)


FROM instructor
GROUP BY dept_name;
a) Dept_id should not be used in group by clause
b) Group by clause is not valid in this query
c) Avg(salary) should not be selected
d) None
View Answer
Answer: a
Explanation: Any property that does not occur in the group by clause
must only appear in an aggregate function if it also appears in the
select clause; otherwise, the query is considered incorrect.
32. The traditional storage of data organized by the customer, stored
in separate folders in filing cabinets is an example of ______________
type of ‘database’ management system.
a) Object-oriented database management system
b) Relational database management system
c) Network database management system
d) Hierarchical database management system
View Answer
Answer: d
Explanation: In an object-oriented database management system,
the data is stored in the form of objects. In a relational DBMS, the
data is stored in the form of tables. Hierarchy is obtained by Parent-
Child Relationship. Parent-Child Relationship Type is basically a 1:N
relationship.
33. After groups have been established, SQL applies predicates in the
___________ clause, allowing aggregate functions to be used.
a) Where
b) Having
c) Group by
d) With
View Answer
Answer: b
Explanation: In SQL, after grouping data using the GROUP BY clause,
the HAVING clause is used to filter the groups based on specific
conditions. It allows the use of aggregate functions and selects only
the groups that satisfy the given criteria.
34. Which of the following is not the utility of DBMS?
i) Backup ii) Loading iii) Process Organization iv) File organization
a) i, ii, and iv only
b) i, ii and iii only
c) i, iii and iv only
d) All i, ii, iii, and iv
View Answer
Answer: a
Explanation: Backup utility is used to create a copy of the db as a
backup. Loading utility is used to load existing file. File organization is
used to relocate the files and create new access path. Processing is
not an utility.
35. What does a foreign key combined with a primary key create?
a) Network model between the tables that connect them
b) Parent-Child relationship between the tables that connects them
c) One to many relationship between the tables that connects them
d) All of the mentioned
View Answer
Answer: a
Explanation: Using the two relationships mother and father gives us
a record of a child’s mother, even if we don’t know who the father is;
if the ternary connection parent is used, a null value is necessary. In
this scenario, binary relationship sets are preferred.
36. Which of the following is correct according to the technology
deployed by DBMS?
a) Pointers are used to maintain transactional integrity and
consistency
b) Cursors are used to maintain transactional integrity and
consistency
c) Locks are used to maintain transactional integrity and consistency
d) Triggers are used to maintain transactional integrity and
consistency
View Answer
Answer: c
Explanation: Pointers are used to access data with great speed and
accuracy. Consistency is maintained using locks.
37. Which of the following is correct regarding the file produced by a
spreadsheet?
a) can be used as it is by the DBMS
b) stored on disk in an ASCII text format
c) all of the mentioned
d) none of the mentioned
View Answer
Answer: a
Explanation: For updating the value in ASCII text format, a regular
text file is used.
38. What is the function of the following command?

Delete from r where P;

a) Clears entries from relation


b) Deletes relation
c) Deletes particular tuple from relation
d) All of the mentioned
View Answer
Answer: c
Explanation: In the command the P gives condition to delete a
particular tuple.
39. ______ resembles Create view.
a) Create table . . . as
b) Create view as
c) Create table . . .like
d) With data
View Answer
Answer: a
Explanation: The ‘create table… as’ statement is similar to the ‘create
view… as’ statement in that both are defined with queries. The main
distinction is that table contents are set when the table is built,
whereas view contents always reflect the current query result.
40. The query specifying the SQL view is said to be updatable if it
meets which of the following conditions?
a) select clause contains relation attribute names but not have
expressions, aggregates, or distinct specification
b) from clause has 1 relation
c) query does not have group by or having clause
d) All of the mentioned
View Answer
Answer: d
Explanation: To update the view in sql all the conditions must be
satisfied.
41. When the “ROLLUP” operator for expression or columns within a
“GROUP BY” clause is used?
a) Find the groups that make up the subtotal in a row
b) Create group-wise grand totals for the groups indicated in a
GROUP BY clause
c) Group expressions or columns specified in a GROUP BY clause in
one direction, from right to left, for computing the subtotals
d) To produce a cross-tabular report for computing subtotals by
grouping phrases or columns given within a GROUP BY clause in all
available directions
View Answer
Answer: c
Explanation: A view can be thought of as a virtual table that gets its
data from one or more table columns.
42. Which of the following is the best way to represent the attributes
in a large db?
a) Dot representation
b) Concatenation
c) Relational-and
d) All of the mentioned
View Answer
Answer: b
Explanation: Concatenation in DBMS is used to join two or more
table fields of the same table or different tables. Example inst sec
and student sec.
43. Which of the following is the subset of SQL commands used to
manipulate Oracle Structures, including tables?
a) Data Described Language
b) Data Retrieval Language
c) Data Manipulation Language
d) Data Definition Language
View Answer
Answer: d
Explanation: DDLs are used to define schema and table characters
and consist of commands that help in modifying. DML performs the
change in the values of the relation.
44. Which of the following functions construct histograms and use
buckets for ranking?
a) Ntil()
b) Newtil()
c) Rank()
d) All of the mentioned
View Answer
Answer: a
Explanation: ntile(n) returns the number of the bucket in which each
tuple is stored, with bucket numbers beginning with 1.
45. __________ command is used in SQL to issue multiple CREATE
TABLE, CREATE VIEW and GRANT statements in a single transaction.
a) CREATE CLUSTER
b) CREATE PACKAGE
c) CREATE SCHEMA
d) All of the mentioned
View Answer
Answer: c
Explanation: A schema is a description of a system’s structure in a
formal language supported by the database management system,
and it refers to data organization as a blueprint for how a db is built.
46. Which of the following key is required in to handle the data when
the encryption is applied to the data so that the unauthorised user
cannot access the data?
a) Primary key
b) Authorised key
c) Encryption key
d) Decryption key
View Answer
Answer: c
Explanation: The encryption key is used to encrypt the message.
Even if the message is intercepted by an enemy, the enemy will be
unable to decrypt and interpret the message because he lacks the
key.
47. Which of the following is known as the process of viewing cross-
tab with a fixed value of one attribute?
a) Dicing
b) Pivoting
c) Slicing
d) Both Pivoting and Dicing
View Answer
Answer: c
Explanation: Slice procedure takes one dimension from a cube and
turns it into a new sub-cube. Dice takes two or more dimensions
from a cube and creates a new sub-cube from them.
48. For designing a normal RDBMS which of the following normal
form is considered adequate?
a) 4NF
b) 3NF
c) 2NF
d) 5NF
View Answer
Answer: b
Explanation: Because most 3NF tables are free of insertion, update,
and deletion anomalies, an RDBMS table is sometimes regarded as
“normalized” if it is in the Third Normal Form.
49. Which of the following is popular for applications such as storage
of log files in a database management system since it offers the best
write performance?
a) RAID level 0
b) RAID level 1
c) RAID level 2
d) RAID level 3
View Answer
Answer: b
Explanation: RAID level 0 refers to data stripping. RAID level 1 refers
to disk mirroring with block striping. RAID level 2 refers to bit-level
stripping and RAID level 3 refers to byte-level striping with dedicated
parity.
50. Which of the following represents a query in the tuple relational
calculus?
a) { }{P(t) | t }
b) {t | P(t)}
c) t | P() | t
d) All of the mentioned
View Answer
Answer: b
Explanation: A nonprocedural query language is the tuple relational
calculus. It specifies the needed information but does not provide a
detailed strategy for obtaining it.
51. The oldest DB model is _______________
a) Network
b) Physical
c) Hierarchical
d) Relational
View Answer
Answer: a
Explanation: Network model has data stored in a hierarchical
network flow. In a relational DBMS, the data is stored in the form of
tables. Hierarchy is obtained by Parent-Child Relationship
52. Evaluate the statements issued by the DBA in the given sequence
if OE and SCOTT are the users and the ORDERS table is owned by OE.

CREATE ROLE r1;


GRANT SELECT, INSERT ON oe. orders TO r1;
GRANT r1 TO scott;
GRANT SELECT ON oe. orders TO scott;
REVOKE SELECT ON oe.orders FROM scott;
What would be the outcome after executing the statements?
a) The REVOKE statement would give an error because the SELECT
privilege has been granted to the role R1
b) The REVOKE statement would remove the SELECT privilege from
SCOTT as well as from the role R1
c) SCOTT would be able to query the OE.ORDERS table
d) SCOTT would not be able to query the OE.ORDERS table
View Answer
Answer: c
Explanation: To perform operations on objects, the REVOKE
statement is used to revoke rights from a single user or role, or from
all users.
53. Which of the following establishes a top-to-bottom relationship
among the items?
a) Relational schema
b) Network schema
c) Hierarchical schema
d) All of the mentioned
View Answer
Answer: c
Explanation: A data model in which the data is structured into a tree-
like structure is known as a hierarchical model. The structure allows
information to be represented using parent-child relationships.
54. A major goal of the db system is to minimize the number of block
transfers between the disk and memory. Which of the following
helps in achieving this goal?
a) Secondary storage
b) Storage
c) Catalog
d) Buffer
View Answer
Answer: d
Explanation: Every block has a copy on disc, however, the copy on
the disc may be an earlier version of the block than the version in the
buffer.
55. What happens if a piece of data is stored in two places in the db?
a) Storage space is wasted & Changing the data in one spot will cause
data inconsistency
b) In can be more easily accessed
c) Changing the data in one spot will cause data inconsistency
d) Storage space is wasted
View Answer
Answer: a
Explanation: One of the main features of a database management
system is minimum data duplication and redundancy. Hence, is
always consistent and so there is no duplication.
56. The logical design, and the snapshot of the data at a given instant
in time is known as?
a) Instance & Relation
b) Relation & Schema
c) Domain & Schema
d) Schema & Instance
View Answer
Answer: d
Explanation: Instance is an instance of time, the relation is also
known as table consists of data with similar characteristics, Domain
is the collection of values that an attribute can contain and schema is
a representation.
1. A relational database consists of a collection of
a) Tables
b) Fields
c) Records
d) Keys
View Answer
Answer: a
Explanation: Fields are the column of the relation or tables. Records
are each row in a relation. Keys are the constraints in a relation.
2. A ________ in a table represents a relationship among a set of
values.
a) Column
b) Key
c) Row
d) Entry
View Answer
Answer: c
Explanation: Column has only one set of values. Keys are constraints
and row is one whole set of attributes. Entry is just a piece of data.
3. The term _______ is used to refer to a row.
a) Attribute
b) Tuple
c) Field
d) Instance
View Answer
Answer: b
Explanation: Tuple is one entry of the relation with several attributes
which are fields.
advertisement
ADVERTISEMENT
ADVERTISEMENT
4. The term attribute refers to a ___________ of a table.
a) Record
b) Column
c) Tuple
d) Key
View Answer
Answer: b
Explanation: Attribute is a specific domain in the relation which has
entries of all tuples.
5. For each attribute of a relation, there is a set of permitted values,
called the ________ of that attribute.
a) Domain
b) Relation
c) Set
d) Schema
View Answer
Answer: a
Explanation: The values of the attribute should be present in the
domain. Domain is a set of values permitted.
Subscribe Now: DBMS Newsletter | Important Subjects
Newsletters
6. Database __________ which is the logical design of the database,
and the database _______ which is a snapshot of the data in the
database at a given instant in time.
a) Instance, Schema
b) Relation, Schema
c) Relation, Domain
d) Schema, Instance
View Answer
Answer: d
Explanation: Instance is an instance of time and schema is a
representation.
7. Course(course_id,sec_id,semester)
Here the course_id,sec_id and semester are __________ and course is
a _________
a) Relations, Attribute
b) Attributes, Relation
c) Tuple, Relation
d) Tuple, Attributes
View Answer
Answer: b
Explanation: The relation course has a set of attributes
course_id,sec_id,semester .
8. Department (dept name, building, budget) and Employee
(employee_id, name, dept name, salary)
Here the dept_name attribute appears in both the relations. Here
using common attributes in relation schema is one way of relating
___________ relations.
a) Attributes of common
b) Tuple of common
c) Tuple of distinct
d) Attributes of distinct
View Answer
Answer: c
Explanation: Here the relations are connected by the common
attributes.
9. A domain is atomic if elements of the domain are considered to be
____________ units.
a) Different
b) Indivisbile
c) Constant
d) Divisible
View Answer
Answer: b
Explanation: None.
10. The tuples of the relations can be of ________ order.
a) Any
b) Same
c) Sorted
d) Constant
View Answer
Answer: a
Explanation: The values only count. The order of the tuples does not
matter.
1. Which one of the following is a set of one or more attributes taken
collectively to uniquely identify a record?
a) Candidate key
b) Sub key
c) Super key
d) Foreign key
View Answer
Answer: c
Explanation: Super key is the superset of all the keys in a relation.
2. Consider attributes ID, CITY and NAME. Which one of this can be
considered as a super key?
a) NAME
b) ID
c) CITY
d) CITY, ID
View Answer
Answer: b
Explanation: Here the id is the only attribute which can be taken as a
key. Other attributes are not uniquely identified.
3. The subset of a super key is a candidate key under what condition?
a) No proper subset is a super key
b) All subsets are super keys
c) Subset is a super key
d) Each subset is a super key
View Answer
Answer: a
Explanation: The subset of a set cannot be the same set. Candidate
key is a set from a super key which cannot be the whole of the super
set.
advertisement
4. A _____ is a property of the entire relation, rather than of the
individual tuples in which each tuple is unique.
a) Rows
b) Key
c) Attribute
d) Fields
View Answer
Answer: b
Explanation: Key is the constraint which specifies uniqueness.
5. Which one of the following attribute can be taken as a primary
key?
a) Name
b) Street
c) Id
d) Department
View Answer
Answer: c
Explanation: The attributes name, street and department can repeat
for some tuples. But the id attribute has to be unique. So it forms a
primary key.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
6. Which one of the following cannot be taken as a primary key?
a) Id
b) Register number
c) Dept_id
d) Street
View Answer
Answer: d
Explanation: Street is the only attribute which can occur more than
once.
7. An attribute in a relation is a foreign key if the _______ key from one
relation is used as an attribute in that relation.
a) Candidate
b) Primary
c) Super
d) Sub
View Answer
Answer: b
Explanation: The primary key has to be referred in the other relation
to form a foreign key in that relation.
8. The relation with the attribute which is the primary key is
referenced in another relation. The relation which has the attribute
as a primary key is called ______________
a) Referential relation
b) Referencing relation
c) Referenced relation
d) Referred relation
View Answer
Answer: c
Explanation: None.
9. The ______ is the one in which the primary key of one relation is
used as a normal attribute in another relation.
a) Referential relation
b) Referencing relation
c) Referenced relation
d) Referred relation
View Answer
Answer: c
Explanation: None.
10. A _________ integrity constraint requires that the values appearing
in specified attributes of any tuple in the referencing relation also
appear in specified attributes of at least one tuple in the referenced
relation.
a) Referential
b) Referencing
c) Specific
d) Primary
View Answer
Answer: a
Explanation: A relation, say r1, may include among its attributes the
primary key of another relation, say r2. This attribute is called a
foreign key from r1, referencing r2. The relation r1 is also called the
referencing relation of the foreign key dependency, and r2 is called
the referenced relation of the foreign key.
1. Using which language can a user request information from a
database?
a) Query
b) Relational
c) Structural
d) Compiler
View Answer
Answer: a
Explanation: Query language is a method through which the
database entries can be accessed.
2. Student(ID, name, dept name, tot_cred)
In this query which attributes form the primary key?
a) Name
b) Dept
c) Tot_cred
d) ID
View Answer
Answer: d
Explanation: The attributes name, dept and tot_cred can have same
values unlike ID.
3. Which one of the following is a procedural language?
a) Domain relational calculus
b) Tuple relational calculus
c) Relational algebra
d) Query language
View Answer
Answer: c
Explanation: Domain and Tuple relational calculus are non-
procedural language. Query language is a method through which
database entries can be accessed.
advertisement
4. The_____ operation allows the combining of two relations by
merging pairs of tuples, one from each relation, into a single tuple.
a) Select
b) Join
c) Union
d) Intersection
View Answer
Answer: b
Explanation: Join finds the common tuple in the relations and
combines it.
5. The result which operation contains all pairs of tuples from the
two relations, regardless of whether their attribute values match.
a) Join
b) Cartesian product
c) Intersection
d) Set difference
View Answer
Answer: b
Explanation: Cartesian product is the multiplication of all the values
in the attributes.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
6. The _______operation performs a set union of two “similarly
structured” tables
a) Union
b) Join
c) Product
d) Intersect
View Answer
Answer: a
Explanation: Union just combines all the values of relations of same
attributes.
7. The most commonly used operation in relational algebra for
projecting a set of tuple from a relation is
a) Join
b) Projection
c) Select
d) Union
View Answer
Answer: c
Explanation: Select is used to view the tuples of the relation with or
without some constraints.
8. The _______ operator takes the results of two queries and returns
only rows that appear in both result sets.
a) Union
b) Intersect
c) Difference
d) Projection
View Answer
Answer: b
Explanation: The union operator gives the result which is the union
of two queries and difference is the one where query which is not a
part of second query.
9. A ________ is a pictorial depiction of the schema of a database that
shows the relations in the database, their attributes, and primary
keys and foreign keys.
a) Schema diagram
b) Relational algebra
c) Database diagram
d) Schema flow
View Answer
Answer: a
Explanation: None.
10. The _________ provides a set of operations that take one or more
relations as input and return a relation as an output.
a) Schematic representation
b) Relational algebra
c) Scheme diagram
d) Relation flow
View Answer
Answer: b
Explanation: None.
1. Which one of the following is used to define the structure of the
relation, deleting relations and relating schemas?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
View Answer
Answer: b
Explanation: Data Definition language is the language which
performs all the operation in defining structure of relation.
2. Which one of the following provides the ability to query
information from the database and to insert tuples into, delete
tuples from, and modify tuples in the database?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
View Answer
Answer: a
Explanation: DML performs the change in the values of the relation.
3.

advertisement
CREATE TABLE employee (name VARCHAR, id INTEGER)
What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
View Answer
Answer: b
Explanation: Data Definition language is the language which
performs all the operation in defining structure of relation.
Subscribe Now: DBMS Newsletter | Important Subjects
Newsletters
4.

SELECT * FROM employee


What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
View Answer
Answer: a
Explanation: Select operation just shows the required fields of the
relation. So it forms a DML.
5. The 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
View Answer
Answer: c
Explanation: Varchar changes its length accordingly whereas char
has a specific length which has to be filled by either letters or spaces.
6. An attribute A of datatype varchar(20) has the value “Avi”. The
attribute B of datatype char(20) has value ”Reed”. Here attribute A
has ____ spaces and attribute B has ____ spaces.
a) 3, 20
b) 20, 4
c) 20, 20
d) 3, 4
View Answer
Answer: a
Explanation: Varchar changes its length accordingly whereas char
has a specific length which has to be filled by either letters or spaces.
7. To remove a relation from an SQL database, we use the ______
command.
a) Delete
b) Purge
c) Remove
d) Drop table
View Answer
Answer: d
Explanation: Drop table deletes the whole structure of the relation
.purge removes the table which cannot be obtained again.
8.

DELETE FROM r; //r - relation


This command performs which of the following action?
a) Remove relation
b) Clear relation entries
c) Delete fields
d) Delete rows
View Answer
Answer: b
Explanation: Delete command removes the entries in the table.
9.
INSERT INTO instructor VALUES (10211, ’Smith’, ’Biology’,
66000);
What type of statement is this?
a) Query
b) DML
c) Relational
d) DDL
View Answer
Answer: b
Explanation: The values are manipulated. So it is a DML.
10. Updates that violate __________ are disallowed.
a) Integrity constraints
b) Transaction control
c) Authorization
d) DDL constraints
View Answer
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
View Answer
Answer: c
Explanation: The field to be displayed is included in select and the
table is included in the from clause.
2. Here which of the following displays the unique values of the
column?

advertisement
ADVERTISEMENT
ADVERTISEMENT
SELECT ________ dept_name
FROM instructor;
a) All
b) From
c) Distinct
d) Name
View Answer
Answer: c
Explanation: Distinct keyword selects only the entries that are
unique.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
3. The ______ clause allows us to select only those rows in the result
relation of the ____ clause that satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where
View Answer
Answer: a
Explanation: Where selects the rows on a particular condition. From
gives the relation which involves the operation.
4. The query given below will not give an error. Which one of the
following has to be replaced to get the desired output?

SELECT ID, name, dept name, salary * 1.1


WHERE instructor;
a) Salary*1.1
b) ID
c) Where
d) Instructor
View Answer
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.
5. The ________ clause is used to list the attributes desired in the
result of a query.
a) Where
b) Select
c) From
d) Distinct
View Answer
Answer: b
Explanation: None
6. This Query can be replaced by which one of the following?

SELECT name, course_id


FROM instructor, teaches
WHERE instructor_ID= teaches_ID;
a) Select name,course_id from teaches,instructor where
instructor_id=course_id;
b) Select name, course_id from instructor natural join teaches;
c) Select name, course_id from instructor;
d) Select course_id from instructor join teaches;
View Answer
Answer: b
Explanation: Join clause joins two tables by matching the common
column.
7.

SELECT * FROM employee WHERE salary>10000 AND dept_id=101;


Which of the following fields are displayed as output?
a) Salary, dept_id
b) Employee
c) Salary
d) All the field of employee relation
View Answer
Answer: d
Explanation: Here * is used to select all the fields of the relation.
8.

Employee_id Name Salary

1001 Annie 6000

1009 Ross 4500

1018 Zeith 7000


This is Employee table.
Which of the following employee_id will be displayed for the given
query?

SELECT * FROM employee WHERE employee_id>1009;


a) 1009, 1001, 1018
b) 1009, 1018
c) 1001
d) 1018
View Answer
Answer: d
Explanation: Greater than symbol does not include the given value
unlike >=.
9. Which of the following statements contains an error?
a) Select * from emp where empid = 10003;
b) Select empid from emp where empid = 10006;
c) Select empid from emp;
d) Select empid where empid = 1009 and lastname = ‘GELLER’;
View Answer
Answer: d
Explanation: This query do not have from clause which specifies the
relation from which the values has to be selected.
10. In the given query which of the keyword has to be inserted?

INSERT INTO employee _____ (1002,Joey,2000);


a) Table
b) Values
c) Relation
d) Field
View Answer
Answer: b
Explanation: Value keyword has to be used to insert the values into
the table.
1.

SELECT name ____ instructor name, course id


FROM instructor, teaches
WHERE instructor.ID= teaches.ID;
Which keyword must be used here to rename the field name?
a) From
b) Rename
c) As
d) Join
View Answer
Answer: c
Explanation: As keyword is used to rename.
advertisement
2.

SELECT * FROM employee WHERE dept_name="Comp Sci";


In the SQL given above there is an error . Identify the error.
a) Dept_name
b) Employee
c) “Comp Sci”
d) From
View Answer
Answer: c
Explanation: For any string operations single quoted(‘) must be used
to enclose.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
3.

SELECT emp_name
FROM department
WHERE dept_name LIKE ’ _____ Computer Science’;
Which one of the following has to be added into the blank to select
the dept_name which has Computer Science as its ending string?
a) %
b) _
c) ||
d) $
View Answer
Answer: a
Explanation: The % character matches any substring.
4. ’_ _ _ ’ matches any string of ______ three characters. ’_ _ _ %’
matches any string of at ______ three characters.
a) Atleast, Exactly
b) Exactly, Atleast
c) Atleast, All
d) All, Exactly
View Answer
Answer: b
Explanation: None.
5.

SELECT name
FROM instructor
WHERE dept name = ’Physics’
ORDER BY name;
By default, the order by clause lists items in ______ order.
a) Descending
b) Any
c) Same
d) Ascending
View Answer
Answer: d
Explanation: Specification of descending order is essential but it not
for ascending.
6.

SELECT *
FROM instructor
ORDER BY salary ____, name ___;
To display the salary from greater to smaller and name in ascending
order which of the following options should be used?
a) Ascending, Descending
b) Asc, Desc
c) Desc, Asc
d) Descending, Ascending
View Answer
Answer: c
Explanation: None.
7.

SELECT name
FROM instructor
WHERE salary <= 100000 AND salary >= 90000;
This query can be replaced by which of the following ?
a)

SELECT name
FROM instructor
WHERE salary BETWEEN 90000 AND 100000;
b)

SELECT name
FROM employee
WHERE salary <= 90000 AND salary>=100000;
c)

SELECT name
FROM employee
WHERE salary BETWEEN 90000 AND 100000;
d)

SELECT name
FROM instructor
WHERE salary BETWEEN 100000 AND 90000;
View Answer
Answer: a
Explanation: SQL includes a between comparison operator to
simplify where clauses that specify that a value be less than or equal
to some value and greater than or equal to some other value.

8.

SELECT instructor.*
FROM instructor, teaches
WHERE instructor.ID= teaches.ID;
This query does which of the following operation?
a) All attributes of instructor and teaches are selected
b) All attributes of instructor are selected on the given condition
c) All attributes of teaches are selected on given condition
d) Only the some attributes from instructed and teaches are selected
View Answer
Answer: b
Explanation: The asterisk symbol “ * ” can be usedin the select clause
to denote “all attributes.”
9. In SQL the spaces at the end of the string are removed by _______
function.
a) Upper
b) String
c) Trim
d) Lower
View Answer
Answer: c
Explanation: The syntax of trim is Trim(s); where s-string.
10. _____ operator is used for appending two strings.
a) &
b) %
c) ||
d) _
View Answer
Answer: c
Explanation: || is the concatenation operator.
1. The union operation is represented by
a) ∩
b) U
c) –
d) *
View Answer
Answer: b
Explanation: Union operator combines the relations.
2. The intersection operator is used to get the _____ tuples.
a) Different
b) Common
c) All
d) Repeating
View Answer
Answer: b
Explanation: Intersection operator ignores unique tuples and takes
only common ones.
3. The union operation automatically __________ unlike the select
clause.
a) Adds tuples
b) Eliminates unique tuples
c) Adds common tuples
d) Eliminates duplicate
View Answer
Answer: d
Explanation: None.
advertisement
4. If we want to retain all duplicates, we must write ________ in place
of union.
a) Union all
b) Union some
c) Intersect all
d) Intersect some
View Answer
Answer: a
Explanation: Union all will combine all the tuples including
duplicates.
5.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
(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
View Answer
Answer: d
Explanation: Except keyword is used to ignore the values.
6. For like predicate which of the following is true.

i) % matches zero OF more characters.


ii) _ matches exactly one CHARACTER.
a) i-only
b) ii-only
c) i & ii
d) None of the mentioned
View Answer
Answer: c
Explanation: The % wildcard matches zero or more characters, while
the _ wildcard matches exactly one character. Together, they offer
flexibility and precision in pattern matching within the like predicate.
7. The number of attributes in relation is called as its
a) Cardinality
b) Degree
c) Tuples
d) Entity
View Answer
Answer: b
Explanation: None.
8. _____ clause is an additional filter that is applied to the result.
a) Select
b) Group-by
c) Having
d) Order by
View Answer
Answer: c
Explanation: Having is used to provide additional aggregate filtration
to the query.
9. _________ joins are SQL server default
a) Outer
b) Inner
c) Equi
d) None of the mentioned
View Answer
Answer: b
Explanation: It is optional to give the inner keyword with the join as it
is default.
10. The _____________ is essentially used to search for patterns in
target string.
a) Like Predicate
b) Null Predicate
c) In Predicate
d) Out Predicate
View Answer
Answer: a
Explanation: Like predicate matches the string in the given pattern.
1. A _____ indicates an absent value that may exist but be unknown or
that may not exist at all.
a) Empty tuple
b) New value
c) Null value
d) Old value
View Answer
Answer: c
Explanation: None.
2. If the attribute phone number is included in the relation all the
values need not be entered into the phone number column. This
type of entry is given as
a) 0
b) –
c) Null
d) Empty space
View Answer
Answer: c
Explanation: Null is used to represent the absence of a value.
3. 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
View Answer
Answer: d
Explanation: None.
advertisement
4.

SELECT name
FROM instructor
WHERE salary IS NOT NULL;
Selects
a) Tuples with null value
b) Tuples with no null values
c) Tuples with any salary
d) All of the mentioned
View Answer
Answer: b
Explanation: Not null constraint removes the tpules of null values.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
5. 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
View Answer
Answer: b
Explanation: Not null constraint removes the tuples of null values.
6. Using the ______ clause retains only one copy of such identical
tuples.
a) Null
b) Unique
c) Not null
d) Distinct
View Answer
Answer: d
Explanation: Unique is a constraint.
7.

CREATE TABLE employee (id INTEGER,name VARCHAR(20),salary


NOT NULL);
INSERT INTO employee VALUES (1005,Rach,0);
INSERT INTO employee VALUES (1007,Ross, );
INSERT INTO employee VALUES (1002,Joey,335);
Some of these insert statements will produce an error. Identify the
statement.
a) Insert into employee values (1005,Rach,0);
b) Insert into employee values (1002,Joey,335);
c) Insert into employee values (1007,Ross, );
d) None of the mentioned
View Answer
Answer: c
Explanation: Not null constraint is specified which means sone value
(can include 0 also) should be given.
8. The primary key must be
a) Unique
b) Not null
c) Both Unique and Not null
d) Either Unique or Not null
View Answer
Answer: c
Explanation: Primary key must satisfy unique and not null condition
for sure.
9. You attempt to query the database with this command:

SELECT nvl (100 / quantity, NONE)


FROM inventory;
Why does this statement cause an error when QUANTITY values are
null?
a) The expression attempts to divide by a null value
b) The data types in the conversion function are incompatible
c) The character string none should be enclosed in single quotes (‘ ‘)
d) A null value used in an expression cannot be converted to an
actual value
View Answer
Answer: a
Explanation: The expression attempts to divide by a null value is
erroneous in sql.
10. The result of _____unknown is unknown.
a) Xor
b) Or
c) And
d) Not
View Answer
Answer: d
Explanation: Since unknown does not hold any value the value
cannot have a reverse value.
1. Aggregate functions are functions that take a ___________ as input
and return a single value.
a) Collection of values
b) Single value
c) Aggregate value
d) Both Collection of values & Single value
View Answer
Answer: a
Explanation: None.
2.

SELECT __________
FROM instructor
WHERE dept name= ’Comp. Sci.’;
Which of the following should be used to find the mean of the salary
?
a) Mean(salary)
b) Avg(salary)
c) Sum(salary)
d) Count(salary)
View Answer
Answer: b
Explanation: Avg() is used to find the mean of the values.
advertisement
3.

Note: Join free Sanfoundry classes at Telegram or Youtube


SELECT COUNT (____ ID)
FROM teaches
WHERE semester = ’Spring’ AND YEAR = 2010;
If we do want to eliminate duplicates, we use the keyword ______in
the aggregate expression.
a) Distinct
b) Count
c) Avg
d) Primary key
View Answer
Answer: a
Explanation: Distinct keyword is used to select only unique items
from the relation.
4. All aggregate functions except _____ ignore null values in their
input collection.
a) Count(attribute)
b) Count(*)
c) Avg
d) Sum
View Answer
Answer: b
Explanation: * is used to select all values including null.
5. A Boolean data type that can take values true, false, and________
a) 1
b) 0
c) Null
d) Unknown
View Answer
Answer: d
Explanation: Unknown values do not take null value but it is not
known.
6. The ____ connective tests for set membership, where the set is a
collection of values produced by a select clause. The ____ connective
tests for the absence of set membership.
a) Or, in
b) Not in, in
c) In, not in
d) In, or
View Answer
Answer: c
Explanation: In checks, if the query has the value but not in checks if
it does not have the value.
7. Which of the following should be used to find all the courses
taught in the Fall 2009 semester but not in the Spring 2010 semester
.
a)

SELECT DISTINCT course id


FROM SECTION
WHERE semester = ’Fall’ AND YEAR= 2009 AND
course id NOT IN (SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010);
b)

SELECT DISTINCT course_id


FROM instructor
WHERE name NOT IN (’Fall’, ’Spring’);
c)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
d)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT
course id, sec id, semester, YEAR
FROM teaches
WHERE teaches.ID= 10101);
View Answer
Answer: a
Explanation: None.
8. The phrase “greater than at least one” is represented in SQL by
_____
a) < all
b) < some
c) > all
d) > some
View Answer
Answer: d
Explanation: >some takes atlest one value above it .
9. Which of the following is used to find all courses taught in both the
Fall 2009 semester and in the Spring 2010 semester .
a)

SELECT course id
FROM SECTION AS S
WHERE semester = ’Fall’ AND YEAR= 2009 AND
EXISTS (SELECT *
FROM SECTION AS T
WHERE semester = ’Spring’ AND YEAR= 2010 AND
S.course id= T.course id);
b)

SELECT name
FROM instructor
WHERE salary > SOME (SELECT salary
FROM instructor
WHERE dept name = ’Biology’);
c)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT
course id, sec id, semester, YEAR
FROM teaches
WHERE teaches.ID= 10101);
d)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
View Answer
Answer: a
Explanation: None.

10. We can test for the nonexistence of tuples in a subquery by using


the _____ construct.
a) Not exist
b) Not exists
c) Exists
d) Exist
View Answer
Answer: b
Explanation: Exists is used to check for the existence of tuples.
1.

SELECT 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
View Answer
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.
advertisement
2. SQL applies predicates in the _______ clause after groups have
been formed, so aggregate functions may be used.
a) Group by
b) With
c) Where
d) Having
View Answer
Answer: d
Explanation: The Having clause in SQL is used to apply predicates
after groups have been formed using the Group By clause. This
allows aggregate functions to be used and filters the grouped data
based on specified conditions.
3. 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
View Answer
Answer: b
Explanation: To include aggregate functions having clause must be
included after where.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
4. The ________ keyword is used to access attributes of preceding
tables or subqueries in the from clause.
a) In
b) Lateral
c) Having
d) With
View Answer
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.
5. Which of the following creates a temporary relation for the query
on which it is defined?
a) With
b) From
c) Where
d) Select
View Answer
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.
6.

WITH max_budget (VALUE) AS


(SELECT MAX(budget)
FROM department)
SELECT budget
FROM department, max_budget
WHERE department.budget = MAX budget.value;
In the query given above which one of the following is a temporary
relation?
a) Budget
b) Department
c) Value
d) Max_budget
View Answer
Answer: d
Explanation: With clause creates a temporary relation.
7. Subqueries cannot:
a) Use group by or group functions
b) Retrieve data from a table different from the one in the outer
query
c) Join tables
d) Appear in select, update, delete, insert statements.
View Answer
Answer: c
Explanation: None.
8. Which of the following is not an aggregate function?
a) Avg
b) Sum
c) With
d) Min
View Answer
Answer: c
Explanation: With is used to create temporary relation and its not an
aggregate function.
9. The EXISTS keyword will be true if:
a) Any row in the subquery meets the condition only
b) All rows in the subquery fail the condition only
c) Both of these two conditions are met
d) Neither of these two conditions is met
View Answer
Answer: a
Explanation: EXISTS keyword checks for existance of a condition.
10. How can you find rows that do not match some specified
condition?
a) EXISTS
b) Double use of NOT EXISTS
c) NOT EXISTS
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
1. A Delete command operates on ______ relation.
a) One
b) Two
c) Several
d) Null
View Answer
Answer: a
Explanation: Delete can delete from only one table at a time.
2.

Delete from r where P;

The above command


a) Deletes a particular tuple from the relation
b) Deletes the relation
c) Clears all entries from the relation
d) All of the mentioned
View Answer
Answer: a
Explanation: Here P gives the condition for deleting specific rows.
advertisement
3. Which one of the following deletes all the entries but keeps the
structure of the relation.
a) Delete from r where P;
b) Delete from instructor where dept name= ’Finance’;
c) Delete from instructor where salary between 13000 and 15000;
d) Delete from instructor;
View Answer
Answer: d
Explanation: Absence of condition deletes all rows.
4. Which of the following is used to insert a tuple from another
relation?
a)

Note: Join free Sanfoundry classes at Telegram or Youtube


INSERT INTO course (course id, title, dept name,
credits)
VALUES (’CS-437’, ’DATABASE Systems’, ’Comp. Sci.’, 4);
b)

INSERT INTO instructor


SELECT ID, name, dept name, 18000
FROM student
WHERE dept name = ’Music’ AND tot cred > 144;
c)

INSERT INTO course VALUES (’CS-437’, ’DATABASE Systems’,


’Comp. Sci.’, 4);
d) Not possible
View Answer
Answer: b
Explanation: Using select statement in insert will include rows which
are the result of the selection.
5. Which of the following deletes all tuples in the instructor relation
for those instructors associated with a department located in the
Watson building which is in department relation.
a)

DELETE FROM instructor


WHERE dept_name IN 'Watson';
b)

DELETE FROM department


WHERE building='Watson';
c)

DELETE FROM instructor


WHERE dept_name IN (SELECT dept name
FROM department
WHERE building = ’Watson’);
d) None of the mentioned
View Answer
Answer: c
Explanation: The query must include building=watson condition to
filter the tuples.
6.

UPDATE instructor
_____ salary= salary * 1.05;
Fill in with correct keyword to update the instructor relation.
a) Where
b) Set
c) In
d) Select
View Answer
Answer: b
Explanation: Set is used to update the particular value.
7. _________ 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
View Answer
Answer: d
Explanation: None.
8. The problem of ordering the update in multiple updates is avoided
using
a) Set
b) Where
c) Case
d) When
View Answer
Answer: c
Explanation: The case statements can add the order of updating
tuples.
9. Which of the following is the correct format for case statements.
a)

CASE
WHEN pred1 ... result1
WHEN pred2 ... result2
. . .
WHEN predn ... resultn
ELSE result0
END
b)

CASE
WHEN pred1 THEN result1
WHEN pred2 THEN result2
. . .
WHEN predn THEN resultn
ELSE result0
END
c)

CASE
WHEN pred1 THEN result1
WHEN pred2 THEN result2
. . .
WHEN predn THEN resultn
ELSE result0
d) All of the mentioned
View Answer
Answer: b
Explanation: None.
10. Which of the following relation updates all instructors with salary
over $100,000 receive a 3 percent raise, whereas all others receive a
5 percent raise.
a)

UPDATE instructor
SET salary = salary * 1.03
WHERE salary > 100000;
UPDATE instructor
SET salary = salary * 1.05
WHERE salary <= 100000;
b)

UPDATE instructor
SET salary = salary * 1.05
WHERE salary < (SELECT avg (salary)
FROM instructor);
c)

UPDATE instructor
SET salary = CASE
WHEN salary <= 100000 THEN salary * 1.03
ELSE salary * 1.05
END
d) None of the mentioned
View Answer
Answer: a
Explanation: The order of the two update statements is important. If
we changed the order of the two statements, an instructor with a
salary just under $100,000 would receive an over 8 percent raise.
SQL provides a case construct that we can use to perform both the
updates with a single update statement, avoiding the problem with
the order of updates.
1. The____condition allows a general predicate over the relations
being joined.
a) On
b) Using
c) Set
d) Where
View Answer
Answer: a
Explanation: On gives the condition for the join expression.
2. Which of the join operations do not preserve non matched tuples?
a) Left outer join
b) Right outer join
c) Inner join
d) Natural join
View Answer
Answer: c
Explanation: INNER JOIN: Returns all rows when there is at least one
match in BOTH tables.
3.

advertisement
SELECT *
FROM student JOIN takes USING (ID);
The above query is equivalent to
a)

Sanfoundry Certification Contest of the Month is Live. 100+


Subjects. Participate Now!
SELECT *
FROM student INNER JOIN takes USING (ID);
b)

SELECT *
FROM student OUTER JOIN takes USING (ID);
c)

SELECT *
FROM student LEFT OUTER JOIN takes USING (ID);
d) None of the mentioned
View Answer
Answer: a
Explanation: Join can be replaced by inner join.
4. What type of join is needed when you wish to include rows that do
not have matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the mentioned
View Answer
Answer: c
Explanation: An outer join does not require each record in the two
joined tables to have a matching record..
5. How many tables may be included with a join?
a) One
b) Two
c) Three
d) All of the mentioned
View Answer
Answer: d
Explanation: Join can combine multiple tables.
6. Which are the join types in join condition:
a) Cross join
b) Natural join
c) Join with USING clause
d) All of the mentioned
View Answer
Answer: d
Explanation: There are totally four join types in SQL.
7. How many join types in join condition:
a) 2
b) 3
c) 4
d) 5
View Answer
Answer: d
Explanation: Types are inner join, left outer join, right outer join, full
join, cross join.
8. Which join refers to join records from the right table that have no
matching key in the left table are include in the result set:
a) Left outer join
b) Right outer join
c) Full outer join
d) Half outer join
View Answer
Answer: b
Explanation: RIGHT OUTER JOIN: Return all rows from the right table
and the matched rows from the left table.
9. The operation which is not considered a basic operation of
relational algebra is
a) Join
b) Selection
c) Union
d) Cross product
View Answer
Answer: a
Explanation: None.
10. 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
View Answer
Answer: b
Explanation: None.
1. Which of the following creates a virtual relation for storing the
query?
a) Function
b) View
c) Procedure
d) None of the mentioned
View Answer
Answer: b
Explanation: Any such relation that is not part of the logical model,
but is made visible to a user as a virtual relation, is called a view.
2. Which of the following is the syntax for views where v is view
name?
a) Create view v as “query name”;
b) Create “query expression” as view;
c) Create view v as “query expression”;
d) Create view “query expression”;
View Answer
Answer: c
Explanation: <query expression> is any legal query expression. The
view name is represented by v.
3.

advertisement
SELECT course_id
FROM physics_fall_2009
WHERE building= ’Watson’;
Here the tuples are selected from the view.Which one denotes the
view.
a) Course_id
b) Watson
c) Building
d) physics_fall_2009
View Answer
Answer: c
Explanation: View names may appear in a query any place where a
relation name may appear.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
4. Materialised views make sure that
a) View definition is kept stable
b) View definition is kept up-to-date
c) View definition is verified for error
d) View is deleted after specified time
View Answer
Answer: b
Explanation: None.
5. Updating the value of the view
a) Will affect the relation from which it is defined
b) Will not change the view definition
c) Will not affect the relation from which it is defined
d) Cannot determine
View Answer
Answer: a
Explanation: None.
6. SQL view is said to be updatable (that is, inserts, updates or
deletes can be applied on the view) if which of the following
conditions are satisfied by the query defining the view?
a) The from clause has only one database relation
b) The query does not have a group by or having clause
c) The select clause contains only attribute names of the relation and
does not have any expressions, aggregates, or distinct specification
d) All of the mentioned
View Answer
Answer: d
Explanation: All of the conditions must be satisfied to update the
view in sql.
7. Which of the following is used at the end of the view to reject the
tuples which do not satisfy the condition in where clause?
a) With
b) Check
c) With check
d) All of the mentioned
View Answer
Answer: c
Explanation: Views can be defined with a with check option clause at
the end of the view definition; then, if a tuple inserted into the view
does not satisfy the view’s where clause condition, the insertion is
rejected by the database system.
8. Consider the two relations instructor and department
Instructor:

ID Name Dept_name Salary

1001 Ted Finance 10000

1002 Bob Music 20000

1003 Ron Physics 50000


Department:

Dept_name Building Budget

Biology Watson 40000

Chemistry Painter 30000

Music Taylor 50000


Which of the following is used to create view for these relations
together?
a)

CREATE VIEW instructor_info AS


SELECT ID, name, building
FROM instructor, department
WHERE instructor.dept name= department.dept name;
b)
CREATE VIEW instructor_info
SELECT ID, name, building
FROM instructor, department;
c)

CREATE VIEW instructor_info AS


SELECT ID, name, building
FROM instructor;
d)

CREATE VIEW instructor_info AS


SELECT ID, name, building
FROM department;
View Answer

9. For the view Create view instructor_info as

SELECT ID, name, building


FROM instructor, department
WHERE instructor.dept name=
department.dept name;
If we insert tuple into the view as insert into instructor info values
(’69987’, ’White’, ’Taylor’);
What will be the values of the other attributes in instructor and
department relations?
a) Default value
b) Null
c) Error statement
d) 0
View Answer
10.

CREATE VIEW faculty AS


SELECT ID, name, dept name
FROM instructor;
Find the error in this query.
a) Instructor
b) Select
c) View …as
d) None of the mentioned
View Answer
Answer: d
Explanation: Syntax is – create view v as <query expression>;.
1. A _________ consists of a sequence of query and/or update
statements.
a) Transaction
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: a
Explanation: Transaction is a set of operation until commit.
2. Which of the following makes the transaction permanent in the
database?
a) View
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: b
Explanation: Commit work commits the current transaction.
3. In order to undo the work of transaction after last commit which
one should be used?
a) View
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: c
Explanation: Rollback work causes the current transaction to be
rolled back; that is, it undoes all the updates performed by the SQL
statements in the transaction.
advertisement
4. Consider the following action:

TRANSACTION.....
Commit;
ROLLBACK;
What does Rollback do?
a) Undoes the transactions before commit
b) Clears all transactions
c) Redoes the transactions before commit
d) No action
View Answer
Answer: d
Explanation: Once a transaction has executed commit work, its
effects can no longer be undone by rollback work.
Subscribe Now: DBMS Newsletter | Important Subjects
Newsletters
5. In case of any shut down during transaction before commit which
of the following statement is done automatically?
a) View
b) Commit
c) Rollback
d) Flashback
View Answer
Answer: c
Explanation: Once a transaction has executed commit work, its
effects can no longer be undone by rollback work.
6. In order to maintain the consistency during transactions, database
provides
a) Commit
b) Atomic
c) Flashback
d) Retain
View Answer
Answer: b
Explanation: By atomic, either all the effects of the transaction are
reflected in the database, or none are (after rollback).
7. 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
View Answer
Answer: a
Explanation: None.
8. A transaction completes its execution is said to be
a) Committed
b) Aborted
c) Rolled back
d) Failed
View Answer
Answer: a
Explanation: A complete transaction always commits.
9. Which of the following is used to get back all the transactions back
after rollback?
a) Commit
b) Rollback
c) Flashback
d) Redo
View Answer
Answer: c
Explanation: None.
10. ______ will undo all statements up to commit?
a) Transaction
b) Flashback
c) Rollback
d) Abort
View Answer
Answer: c
Explanation: Flashback will undo all the statements and Abort will
terminate the operation.
1. To include integrity constraint in an existing relation use :
a) Create table
b) Modify table
c) Alter table
d) Drop table
View Answer
Answer: c
Explanation: SYNTAX – alter table table-name add constraint, where
constraint can be any constraint on the relation.
2. Which of the following is not an integrity constraint?
a) Not null
b) Positive
c) Unique
d) Check ‘predicate’
View Answer
Answer: b
Explanation: Positive is a value and not a constraint.
3.

advertisement
CREATE TABLE Employee(Emp_id NUMERIC NOT NULL, Name
VARCHAR(20) , dept_name VARCHAR(20), Salary NUMERIC
UNIQUE(Emp_id,Name));
INSERT INTO Employee VALUES(1002, Ross, CSE, 10000)
INSERT INTO Employee VALUES(1006,Ted,Finance, );
INSERT INTO Employee VALUES(1002,Rita,Sales,20000);
What will be the result of the query?
a) All statements executed
b) Error in create statement
c) Error in insert into Employee values(1006,Ted,Finance, );
d) Error in insert into Employee values(1008,Ross,Sales,20000);
View Answer
Answer: d
Explanation: The not null specification prohibits the insertion of a
null value for the attribute.
The unique specification says that no two tuples in the relation can
be equal on all the listed attributes.
4.

Sanfoundry Certification Contest of the Month is Live. 100+


Subjects. Participate Now!
CREATE TABLE Manager(ID NUMERIC,Name VARCHAR(20),budget
NUMERIC,Details VARCHAR(30));
Inorder to ensure that the value of budget is non-negative which of
the following should be used?
a) Check(budget>0)
b) Check(budget<0)
c) Alter(budget>0)
d) Alter(budget<0)
View Answer
Answer: a
Explanation: A common use of the check clause is to ensure that
attribute values satisfy specified conditions, in effect creating a
powerful type system.
5. Foreign key is the one in which the ________ of one relation is
referenced in another relation.
a) Foreign key
b) Primary key
c) References
d) Check constraint
View Answer
Answer: b
Explanation: The foreign-key declaration specifies that for each
course tuple, the department name specified in the tuple must exist
in the department relation.
6.

CREATE TABLE course


( . . .
FOREIGN KEY (dept name) REFERENCES department
. . . );
Which of the following is used to delete the entries in the referenced
table when the tuple is deleted in course table?
a) Delete
b) Delete cascade
c) Set null
d) All of the mentioned
View Answer
Answer: b
Explanation: The delete “cascades” to the course relation, deletes the
tuple that refers to the department that was deleted.
7. Domain constraints, functional dependency and referential
integrity are special forms of _________
a) Foreign key
b) Primary key
c) Assertion
d) Referential constraint
View Answer
Answer: c
Explanation: An assertion is a predicate expressing a condition we
wish the database to always satisfy.
8. Which of the following is the right syntax for the assertion?
a) Create assertion ‘assertion-name’ check ‘predicate’;
b) Create assertion check ‘predicate’ ‘assertion-name’;
c) Create assertions ‘predicates’;
d) All of the mentioned
View Answer
Answer: a
Explanation: None.
9. Data integrity constraints are used to:
a) Control who is allowed access to the data
b) Ensure that duplicate records are not entered into the table
c) Improve the quality of data entered for a specific property (i.e.,
table column)
d) Prevent users from changing the values stored in the table
View Answer
Answer: c
Explanation: None.
10. Which of the following can be addressed by enforcing a
referential integrity constraint?
a) All phone numbers must include the area code
b) Certain fields are required (such as the email address, or phone
number) before the record is accepted
c) Information on the customer must be known before anything can
be sold to that customer
d) When entering an order quantity, the user must input a number
and not some text (i.e., 12 rather than ‘a dozen’)
View Answer
Answer: c
Explanation: The information can be referred to and obtained.
1. Dates must be specified in the format
a) mm/dd/yy
b) yyyy/mm/dd
c) dd/mm/yy
d) yy/dd/mm
View Answer
Answer: b
Explanation: yyyy/mm/dd is the default format in sql.
2. 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
View Answer
Answer: a
Explanation: Index is the reference to the tuples in a relation.
3.

Create index studentID_index on student(ID);

advertisement
Here which one denotes the relation for which index is created?
a) StudentID_index
b) ID
c) StudentID
d) Student
View Answer
Answer: d
Explanation: The statement creates an index named studentID index
on the attribute ID of the relation student.
4. Which of the following is used to store movie and image files?
a) Clob
b) Blob
c) Binary
d) Image
View Answer
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”.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
5. The user defined data type can be created using
a) Create datatype
b) Create data
c) Create definetype
d) Create type
View Answer
Answer: d
Explanation: The create type clause can be used to define new
types.Syntax : create type Dollars as numeric(12,2) final; .
6. 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
View Answer
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.
7.

CREATE DOMAIN YearlySalary NUMERIC(8,2)


CONSTRAINT salary VALUE test __________;
In order to ensure that an instructor’s salary domain allows only
values greater than a specified value use:
a) Value>=30000.00
b) Not null;
c) Check(value >= 29000.00);
d) Check(value)
View Answer
Answer: c
Explanation: Check(value ‘condition’) is the syntax.
8. Which of the following closely resembles Create view?
a) Create table . . .like
b) Create table . . . as
c) With data
d) Create view as
View Answer
Answer: b
Explanation: The ‘create table . . . as’ statement closely resembles the
create view statement and both are defined by using queries. The
main difference is that the contents of the table are set when the
table is created, whereas the contents of a view always reflect the
current query result.
9. In contemporary databases, the top level of the hierarchy consists
of ______ each of which can contain _____
a) Catalogs, schemas
b) Schemas, catalogs
c) Environment, schemas
d) Schemas, Environment
View Answer
Answer: a
Explanation: None.
10. Which of the following statements creates a new table temp
instructor that has the same schema as an instructor.
a) create table temp_instructor;
b) Create table temp_instructor like instructor;
c) Create Table as temp_instructor;
d) Create table like temp_instructor;
View Answer
Answer: b
Explanation: None.
1. The database administrator who authorizes all the new users,
modifies the database and takes grants privilege is
a) Super user
b) Administrator
c) Operator of operating system
d) All of the mentioned
View Answer
Answer: d
Explanation: The authorizations provided by the administrator to the
user is a privilege.
2. Which of the following is a basic form of grant statement?
a)

GRANT 'privilege list'


ON 'relation name or view name'
TO 'user/role list';
b)

advertisement
ADVERTISEMENT
ADVERTISEMENT
GRANT 'privilege list'
ON 'user/role list'
TO 'relation name or view name';
c)

Note: Join free Sanfoundry classes at Telegram or Youtube


GRANT 'privilege list'
TO 'user/role list'
d)

GRANT 'privilege list'


ON 'relation name or view name'
ON 'user/role list';
View Answer
Answer: a
Explanation: The privilege list allows the granting of several privileges
in one command .

3. Which of the following is used to provide privilege to only a


particular attribute?
a) Grant select on employee to Amit
b) Grant update(budget) on department to Raj
c) Grant update(budget,salary,Rate) on department to Raj
d) Grant delete to Amit
View Answer
Answer: b
Explanation: This grant statement gives user Raj update
authorization on the budget attribute of the department relation.
4. Which of the following statement is used to remove the privilege
from the user Amir?
a) Remove update on department from Amir
b) Revoke update on employee from Amir
c) Delete select on department from Raj
d) Grant update on employee from Amir
View Answer
Answer: b
Explanation: revoke on from ;
5. Which of the following is used to provide delete authorization to
instructor?
a)

CREATE ROLE instructor ;


GRANT DELETE TO instructor;
b)

CREATE ROLE instructor;


GRANT SELECT ON takes
TO instructor;
c)

CREATE ROLE instructor;


GRANT DELETE ON takes
TO instructor;
d) All of the mentioned
View Answer
Answer: c
Explanation: The role is first created and the authorization is given
on relation takes to the role.
6. Which of the following is true regarding views?
a) The user who creates a view cannot be given update authorization
on a view without having update authorization on the relations used
to define the view
b) The user who creates a view cannot be given update authorization
on a view without having update authorization on the relations used
to define the view
c) If a user creates a view on which no authorization can be granted,
the system will allow the view creation request
d) A user who creates a view receives all privileges on that view
View Answer
Answer: c
Explanation: A user who creates a view does not necessarily receive
all privileges on that view.
7. If we wish to grant a privilege and to allow the recipient to pass the
privilege on to other users, we append the __________ clause to the
appropriate grant command.
a) With grant
b) Grant user
c) Grant pass privelege
d) With grant option
View Answer
Answer: d
Explanation: None.
8. In authorization graph, if DBA provides authorization to u1 which
inturn gives to u2 which of the following is correct?
a) If DBA revokes authorization from u1 then u2 authorization is also
revoked
b) If u1 revokes authorization from u2 then u2 authorization is
revoked
c) If DBA & u1 revokes authorization from u1 then u2 authorization is
also revoked
d) If u2 revokes authorization then u1 authorization is revoked
View Answer
Answer: c
Explanation: A user has an authorization if and only if there is a path
from the root of the authorization graph down to the node
representing the user.
9. Which of the following is used to avoid cascading of authorizations
from the user?
a) Granted by current role
b) Revoke select on department from Amit, Satoshi restrict;
c) Revoke grant option for select on department from Amit;
d) Revoke select on department from Amit, Satoshi cascade;
View Answer
Answer: b
Explanation: The revoke statement may specify restrict in order to
prevent cascading revocation. The keyword cascade can be used
instead of restrict to indicate that revocation should cascade.
10. The granting and revoking of roles by the user may cause some
confusions when that user role is revoked. To overcome the above
situation
a) The privilege must be granted only by roles
b) The privilege is granted by roles and users
c) The user role cannot be removed once given
d) By restricting the user access to the roles
View Answer
Answer: a
Explanation: The current role associated with a session can be set by
executing set role name. The specified role must have been granted
to the user, else the set role statement fails.

SELECT 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
View Answer
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.
advertisement
2. SQL applies predicates in the _______ clause after groups have
been formed, so aggregate functions may be used.
a) Group by
b) With
c) Where
d) Having
View Answer
Answer: d
Explanation: The Having clause in SQL is used to apply predicates
after groups have been formed using the Group By clause. This
allows aggregate functions to be used and filters the grouped data
based on specified conditions.
3. 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
View Answer
Answer: b
Explanation: To include aggregate functions having clause must be
included after where.
Sanfoundry Certification Contest of the Month is Live. 100+
Subjects. Participate Now!
4. The ________ keyword is used to access attributes of preceding
tables or subqueries in the from clause.
a) In
b) Lateral
c) Having
d) With
View Answer
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.
5. Which of the following creates a temporary relation for the query
on which it is defined?
a) With
b) From
c) Where
d) Select
View Answer
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.
6.

WITH max_budget (VALUE) AS


(SELECT MAX(budget)
FROM department)
SELECT budget
FROM department, max_budget
WHERE department.budget = MAX budget.value;
In the query given above which one of the following is a temporary
relation?
a) Budget
b) Department
c) Value
d) Max_budget
View Answer
Answer: d
Explanation: With clause creates a temporary relation.
7. Subqueries cannot:
a) Use group by or group functions
b) Retrieve data from a table different from the one in the outer
query
c) Join tables
d) Appear in select, update, delete, insert statements.
View Answer
Answer: c
Explanation: None.
8. Which of the following is not an aggregate function?
a) Avg
b) Sum
c) With
d) Min
View Answer
Answer: c
Explanation: With is used to create temporary relation and its not an
aggregate function.
9. The EXISTS keyword will be true if:
a) Any row in the subquery meets the condition only
b) All rows in the subquery fail the condition only
c) Both of these two conditions are met
d) Neither of these two conditions is met
View Answer
Answer: a
Explanation: EXISTS keyword checks for existance of a condition.
10. How can you find rows that do not match some specified
condition?
a) EXISTS
b) Double use of NOT EXISTS
c) NOT EXISTS
d) None of the mentioned
View Answer
Answer: b
Explanation: None.

You might also like