0% found this document useful (0 votes)
4 views36 pages

Unit 6

The document outlines key topics in Database Management Systems (DBMS), focusing on comparisons with traditional file systems, the relational model and its keys, and normalization principles. It provides a series of multiple-choice questions and answers to reinforce understanding of these concepts, including advantages of DBMS, types of keys, and normalization forms. Key takeaways emphasize the importance of data independence, ER model notations, and Codd's rules for relational databases.
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)
4 views36 pages

Unit 6

The document outlines key topics in Database Management Systems (DBMS), focusing on comparisons with traditional file systems, the relational model and its keys, and normalization principles. It provides a series of multiple-choice questions and answers to reinforce understanding of these concepts, including advantages of DBMS, types of keys, and normalization forms. Key takeaways emphasize the importance of data independence, ER model notations, and Codd's rules for relational databases.
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/ 36

Great!

Based on Unit 6 (Database Management System)

Selected High-Probability Topics for MCQs:

1. DBMS vs. Traditional File System (advantages, architecture)

2. Relational Model & Keys (primary, foreign, candidate keys)

3. ER Model and ER to Relational Conversion

4. Normalization (1NF, 2NF, 3NF, BCNF)

5. Transactions and Concurrency Control

Topic 1: DBMS vs. Traditional File System & Architecture with detailed explanations:

1. Which of the following is not an advantage of using a DBMS over a file-based system?

A) Reduced data redundancy


B) Improved data integrity
C) Increased data isolation
D) Improved data security

Answer: C) Increased data isolation


Explanation: DBMS reduces data isolation by integrating data. File-based systems suffer from
higher data isolation.

2. What does the 3-level architecture of DBMS help achieve?

A) Better storage
B) Data abstraction
C) Faster input
D) Enhanced encryption

Answer: B) Data abstraction


Explanation: The 3-level architecture (internal, conceptual, external) provides abstraction from
data storage details.

3. In DBMS, what does the external level represent?


A) Physical data
B) User view
C) System view
D) Database index

Answer: B) User view


Explanation: The external level represents how individual users interact with the data.

4. Which of the following is not a component of a DBMS?

A) Query processor
B) Transaction manager
C) Compiler
D) File manager

Answer: C) Compiler
Explanation: Compiler is part of programming environments, not DBMS components.

5. What is the function of the conceptual level in DBMS?

A) Describe how data is stored


B) Provide user views
C) Describe the structure of the entire database
D) Encrypt data

Answer: C) Describe the structure of the entire database


Explanation: Conceptual level gives a community user view of the entire database.

6. The internal level in DBMS refers to:

A) Data encryption
B) User interface
C) Physical storage of data
D) Conceptual relationships

Answer: C) Physical storage of data


Explanation: Internal level describes how data is physically stored.
7. Which of these is a disadvantage of a file-based system?

A) Centralized control
B) Difficulty in enforcing security
C) Easy data sharing
D) Minimal redundancy

Answer: B) Difficulty in enforcing security


Explanation: File systems lack advanced access controls that DBMS offers.

8. Data abstraction in DBMS means:

A) Removing data
B) Data encryption
C) Hiding low-level details
D) Providing user interface

Answer: C) Hiding low-level details


Explanation: DBMS hides complex storage details from the user through abstraction.

9. Mapping between levels in 3-schema architecture is required for:

A) Backup
B) Data conversion
C) Consistency
D) Data independence

Answer: D) Data independence


Explanation: Mappings help maintain data independence—changes in schema at one level
don’t affect others.

10. Which term describes changing data format in DBMS architecture without affecting
application programs?

A) Data control
B) Data integrity
C) Logical data independence
D) Data redundancy
Answer: C) Logical data independence
Explanation: Logical data independence allows changes in the logical schema without altering
applications.

11. Which of these is not part of DBMS 3-level architecture?

A) Internal level
B) Abstract level
C) Conceptual level
D) External level

Answer: B) Abstract level


Explanation: The three levels are internal, conceptual, and external—abstract level is not a
defined level.

12. The 3-schema architecture is proposed by:

A) Codd
B) ANSI/SPARC
C) Oracle
D) Microsoft

Answer: B) ANSI/SPARC
Explanation: ANSI/SPARC proposed the 3-schema architecture model for DBMS systems.

13. Reducing data duplication is achieved in DBMS by:

A) Using multiple files


B) Centralized data control
C) Increasing memory
D) Using file-based system

Answer: B) Centralized data control


Explanation: DBMS stores data centrally and avoids unnecessary duplication.

14. DBMS allows:


A) Application-dependent data
B) Data stored in isolated files
C) Data sharing across multiple users
D) Manual concurrency

Answer: C) Data sharing across multiple users


Explanation: DBMS supports multi-user environments and data sharing.

15. Which of the following does not contribute to the complexity of a traditional file-based
system?

A) Data redundancy
B) File formats differ
C) Lack of concurrency control
D) Logical abstraction

Answer: D) Logical abstraction


Explanation: File-based systems lack logical abstraction—a feature of DBMS.

16. In file-based systems, inconsistency occurs due to:

A) Data redundancy
B) Use of SQL
C) Use of RDBMS
D) Use of foreign keys

Answer: A) Data redundancy


Explanation: Multiple copies of data can lead to inconsistencies in file-based systems.

17. Which term refers to ability to change the storage structure without affecting application
programs?

A) Physical data independence


B) Logical data independence
C) Data abstraction
D) Data normalization
Answer: A) Physical data independence
Explanation: Physical data independence means changes to internal level don't affect
applications.

18. Which is not a key feature of DBMS?

A) Data consistency
B) Program-data dependence
C) Concurrent access
D) Centralized control

Answer: B) Program-data dependence


Explanation: DBMS removes program-data dependence, unlike file systems.

19. The main purpose of DBMS is to:

A) Store large images


B) Manage and retrieve data efficiently
C) Scan hardware
D) Detect viruses

Answer: B) Manage and retrieve data efficiently


Explanation: DBMS focuses on efficient data handling and retrieval.

20. What helps DBMS to enforce data integrity?

A) Separate files
B) Data dictionaries and constraints
C) Use of BIOS
D) More storage

Answer: B) Data dictionaries and constraints


Explanation: DBMS uses constraints and metadata to ensure data integrity.

Key Takeaways:

 Focus on 3-schema architecture, data independence, DBMS components, and


comparison with file-based systems.
 ANSI/SPARC model is frequently asked.

 Questions often test understanding of advantages/disadvantages of DBMS.

Topic 2: Relational Model & Keys (including ER Model) with detailed explanations:

1. In the relational model, each row in a table represents a:

A) Schema
B) Attribute
C) Record or tuple
D) Domain

Answer: C) Record or tuple


Explanation: A row is called a tuple in relational terminology, representing a single record.

2. What is the term for the columns of a relational table?

A) Entities
B) Attributes
C) Tuples
D) Keys

Answer: B) Attributes
Explanation: Each column in a table is called an attribute.

3. A super key is:

A) A key that uniquely identifies a record


B) A subset of primary key
C) Only one attribute
D) Not used in the relational model

Answer: A) A key that uniquely identifies a record


Explanation: A super key may consist of one or more attributes that uniquely identify a row.

4. A candidate key is:


A) Always a foreign key
B) A subset of super key
C) The only key in a table
D) A non-unique key

Answer: B) A subset of super key


Explanation: Candidate keys are minimal super keys; they uniquely identify tuples.

5. A foreign key is:

A) A primary key in the same table


B) A unique key
C) A key that refers to the primary key of another table
D) Not required for relational integrity

Answer: C) A key that refers to the primary key of another table


Explanation: Foreign key enforces referential integrity between related tables.

6. The ER model represents:

A) Physical structure of data


B) High-level conceptual design
C) Internal schema
D) Data flow

Answer: B) High-level conceptual design


Explanation: Entity-Relationship (ER) model is used for high-level database design.

7. The relation between entities is called:

A) Attribute
B) Foreign key
C) Relationship
D) Tuple

Answer: C) Relationship
Explanation: Relationships define associations among entities in ER models.
8. Which of the following is not a type of relationship in an ER model?

A) One-to-one
B) One-to-many
C) Many-to-many
D) Many-to-one-to-one

Answer: D) Many-to-one-to-one
Explanation: Only 1:1, 1:N, and M:N relationships exist.

9. The property that an attribute cannot have multiple values is:

A) Atomicity
B) Normalization
C) Integrity
D) Key constraint

Answer: A) Atomicity
Explanation: Attributes should be atomic (indivisible) in the relational model.

10. An entity set is:

A) A set of relationships
B) A set of tuples
C) A set of entities of the same type
D) A primary key

Answer: C) A set of entities of the same type


Explanation: Entity set contains entities sharing the same attributes.

11. Which key enforces entity integrity in a relation?

A) Foreign key
B) Candidate key
C) Super key
D) Primary key

Answer: D) Primary key


Explanation: Primary key ensures uniqueness and non-null values—ensures entity integrity.
12. Which key can accept null values?

A) Primary key
B) Foreign key
C) Candidate key
D) Super key

Answer: B) Foreign key


Explanation: Foreign keys can accept nulls if no matching primary key exists.

13. Total participation of an entity in a relationship is denoted by:

A) Dotted line
B) Arrowhead
C) Double rectangle
D) Double line

Answer: D) Double line


Explanation: In ER diagrams, total participation is shown by a double line.

14. What represents a weak entity?

A) Has its own primary key


B) Depends on a strong entity and has partial key
C) Is self-dependent
D) Is independent and unique

Answer: B) Depends on a strong entity and has partial key


Explanation: Weak entity lacks a primary key and depends on a strong entity.

15. Derived attribute is represented in ER diagram by:

A) Rectangle
B) Double ellipse
C) Dotted ellipse
D) Diamond
Answer: C) Dotted ellipse
Explanation: Derived attributes (e.g., age from DOB) are shown using dotted ellipse.

16. In ER model, which symbol represents a relationship?

A) Ellipse
B) Rectangle
C) Diamond
D) Line

Answer: C) Diamond
Explanation: Relationships are represented by diamonds.

17. The term “Cardinality” in ER model refers to:

A) Number of rows
B) Number of columns
C) Number of relationships
D) Number of entity instances that can be related

Answer: D) Number of entity instances that can be related


Explanation: Cardinality describes how many instances of one entity relate to another.

18. The primary key is a:

A) Redundant field
B) Field that must have unique and non-null values
C) Field with duplicated values
D) Foreign key

Answer: B) Field that must have unique and non-null values


Explanation: Primary key uniquely identifies each row in the table.

19. Which key is derived from the ER model and implemented in the relational model?

A) Surrogate key
B) Alternate key
C) Foreign key
D) Composite key

Answer: C) Foreign key


Explanation: Foreign keys are derived from relationships in the ER model.

20. The process of transforming an ER diagram into a relational schema involves:

A) Adding redundancy
B) Eliminating relationships
C) Mapping entities and relationships to tables
D) Encrypting data

Answer: C) Mapping entities and relationships to tables


Explanation: ER-to-relational mapping converts entities, attributes, and relationships into
tables and keys.

Key Takeaways:

 Focus on types of keys (primary, foreign, candidate, super).

 Understand ER diagram notations and relationship types.

 Know how to convert ER to relational schema.

 Pay attention to participation, cardinality, and weak/strong entities.

Topic 3: Normalization and Codd’s Rules with detailed explanations:

1. What is the main purpose of normalization?

A) Increase data redundancy


B) Eliminate data redundancy and inconsistency
C) Speed up database queries
D) Reduce storage space

Answer: B) Eliminate data redundancy and inconsistency


Explanation: Normalization reduces data duplication and ensures data integrity.
2. Which of the following is the first step in normalization?

A) Identify primary key


B) Remove partial dependency
C) Remove multivalued attributes
D) Remove repeating groups

Answer: D) Remove repeating groups


Explanation: Removing repeating groups is the first step in converting to First Normal Form
(1NF).

3. A table is in 1NF if:

A) It has a primary key


B) It has no multivalued attributes
C) It is free from transitive dependency
D) It has no partial dependency

Answer: B) It has no multivalued attributes


Explanation: 1NF requires atomic (indivisible) values and no repeating groups.

4. A relation is in 2NF if:

A) It is in 1NF and has a composite key


B) It is in 1NF and has no partial dependency
C) It is in 1NF and has no transitive dependency
D) It is in BCNF

Answer: B) It is in 1NF and has no partial dependency


Explanation: 2NF eliminates partial dependencies (only applies when there’s a composite key).

5. A relation is in 3NF if:

A) It is in 2NF and has no partial dependency


B) It is in 2NF and every non-key attribute is non-transitively dependent on primary key
C) It is in 1NF and has a foreign key
D) It has only one candidate key
Answer: B) It is in 2NF and every non-key attribute is non-transitively dependent on primary key
Explanation: 3NF removes transitive dependencies.

6. Which normal form removes transitive dependency?

A) 1NF
B) 2NF
C) 3NF
D) BCNF

Answer: C) 3NF
Explanation: 3NF removes transitive dependencies to ensure non-key attributes are only
dependent on primary key.

7. A relation is in BCNF if:

A) It is in 3NF and every determinant is a candidate key


B) It is in 3NF and has a foreign key
C) It is in 2NF and has a composite key
D) It has no transitive dependency

Answer: A) It is in 3NF and every determinant is a candidate key


Explanation: Boyce-Codd Normal Form (BCNF) is stricter than 3NF.

8. What type of dependency does BCNF eliminate that 3NF may not?

A) Functional dependency
B) Partial dependency
C) Transitive dependency
D) Anomalous dependency

Answer: A) Functional dependency


Explanation: BCNF handles all functional dependencies even when 3NF does not.

9. Which of the following is an anomaly that normalization removes?

A) Deadlock
B) Redundancy
C) Transaction failure
D) Indexing

Answer: B) Redundancy
Explanation: Normalization reduces data redundancy and anomalies like insertion, deletion,
and update issues.

10. A transitive dependency occurs when:

A) A non-prime attribute depends on a candidate key


B) A non-key attribute depends on another non-key attribute
C) Two tables have the same primary key
D) A table has more than one foreign key

Answer: B) A non-key attribute depends on another non-key attribute


Explanation: This violates 3NF and causes update anomalies.

11. Who proposed the 12 rules of a relational database system?

A) Donald Chamberlin
B) Edgar F. Codd
C) Charles Babbage
D) Chris Date

Answer: B) Edgar F. Codd


Explanation: Dr. E.F. Codd introduced 12 rules for an ideal RDBMS.

12. Codd's Rule 1 is:

A) The system must support multi-user access


B) The information rule – all data should be stored in tables
C) All attributes must have unique names
D) Data should be encrypted

Answer: B) The information rule – all data should be stored in tables


Explanation: Rule 1 of Codd’s rules focuses on storing data as values in tables.
13. Which rule enforces that every data item should be accessible using a combination of
table name, primary key and attribute?

A) Integrity rule
B) Logical data independence
C) Systematic treatment of null values
D) Guaranteed access rule

Answer: D) Guaranteed access rule


Explanation: It ensures data accessibility using relational schema.

14. The purpose of Codd's rules was to:

A) Improve transaction speed


B) Define criteria for a full relational database system
C) Reduce power consumption
D) Enable distributed database

Answer: B) Define criteria for a full relational database system


Explanation: Codd’s 12 rules help evaluate the relational capabilities of a DBMS.

15. What is partial dependency?

A) Non-prime attribute depends only on part of the composite key


B) Foreign key referencing partial rows
C) A key depending on a non-key attribute
D) Dependency within a primary key

Answer: A) Non-prime attribute depends only on part of the composite key


Explanation: Partial dependency violates 2NF.

16. Which of the following is a result of poor normalization?

A) Faster access
B) Data consistency
C) Insertion anomaly
D) Greater integrity
Answer: C) Insertion anomaly
Explanation: Anomalies (insertion, deletion, update) occur in unnormalized tables.

17. A table with multivalued attributes violates which normal form?

A) 1NF
B) 2NF
C) 3NF
D) BCNF

Answer: A) 1NF
Explanation: 1NF requires all attributes to be atomic.

18. Functional dependency is a relationship between:

A) Tables
B) Attributes
C) Rows
D) Keys

Answer: B) Attributes
Explanation: A functional dependency exists when one attribute determines another.

19. In a normalized table:

A) Data duplication increases


B) Queries become complex
C) Data redundancy decreases
D) Relationships become hidden

Answer: C) Data redundancy decreases


Explanation: Main goal of normalization is to reduce redundancy.

20. What is the correct order of normal forms from lowest to highest?

A) BCNF → 1NF → 2NF → 3NF


B) 3NF → 2NF → 1NF
C) 1NF → 2NF → 3NF → BCNF
D) 2NF → 1NF → 3NF → BCNF

Answer: C) 1NF → 2NF → 3NF → BCNF


Explanation: Normalization progresses through these stages.

Key Takeaways:

 1NF → Remove repeating groups/multivalued attributes

 2NF → Remove partial dependency

 3NF → Remove transitive dependency

 BCNF → Every determinant must be a candidate key

 Codd’s rules outline how relational databases should operate

Topic 4: Transactions & Concurrency Control with detailed explanations:

1. What is a transaction in a DBMS?

A) A function call in SQL


B) A group of operations treated as a single unit
C) A trigger execution
D) A data backup process

Answer: B) A group of operations treated as a single unit


Explanation: A transaction is a sequence of one or more operations that are executed as a
single logical unit of work.

2. Which of the following is NOT a property of a transaction (ACID)?

A) Atomicity
B) Consistency
C) Isolation
D) Durability
E) Redundancy

Answer: E) Redundancy
Explanation: ACID stands for Atomicity, Consistency, Isolation, Durability.
3. The isolation property of a transaction ensures:

A) Transactions are stored permanently


B) Transactions execute independently of other concurrent transactions
C) Data is compressed
D) Transactions are rolled back

Answer: B) Transactions execute independently of other concurrent transactions


Explanation: Isolation ensures that the result of concurrent transactions is the same as if they
were executed serially.

4. Atomicity means:

A) All operations are executed at the same time


B) Either all operations of the transaction are completed or none
C) Data is encrypted
D) Transaction is run in parallel

Answer: B) Either all operations of the transaction are completed or none


Explanation: Atomicity ensures "all or nothing" behavior.

5. What does durability ensure in a transaction?

A) Data can be edited after commit


B) Effects of committed transactions are permanent
C) Transaction will not run in parallel
D) Temporary storage

Answer: B) Effects of committed transactions are permanent


Explanation: Durability means changes made by a transaction persist even in the case of
system failure.

6. What is a serial schedule?

A) Two transactions execute concurrently


B) One transaction executes at a time without overlapping
C) Transactions are scheduled using timestamps
D) Transactions are rolled back on failure

Answer: B) One transaction executes at a time without overlapping


Explanation: A serial schedule executes one transaction completely before starting another.

7. Which of the following problems may occur in concurrent transactions?

A) Deadlock
B) Lost update
C) Dirty read
D) All of the above

Answer: D) All of the above


Explanation: All these are common concurrency issues.

8. What is a dirty read?

A) Reading data written by a committed transaction


B) Reading old backup data
C) Reading data written by an uncommitted transaction
D) Reading duplicate data

Answer: C) Reading data written by an uncommitted transaction


Explanation: Dirty reads may lead to inconsistent results.

9. Which of the following techniques is used for concurrency control?

A) Encryption
B) Locking
C) Backup
D) Redundancy

Answer: B) Locking
Explanation: Locking is the most common method to control concurrent access to data.

10. What is a shared lock?


A) A lock that allows only reading
B) A lock that allows both reading and writing
C) A lock that blocks the transaction
D) A lock that deletes data

Answer: A) A lock that allows only reading


Explanation: Shared lock allows multiple transactions to read but not write.

11. What is a two-phase locking protocol?

A) Locking in only the first two transactions


B) Locking and unlocking in separate phases
C) Locking based on timestamps
D) A deadlock detection algorithm

Answer: B) Locking and unlocking in separate phases


Explanation: Two-Phase Locking (2PL) has a growing phase (acquire locks) and a shrinking
phase (release locks).

12. Which of the following ensures serializability?

A) Shadow paging
B) Timestamp ordering
C) Logging
D) Redundancy

Answer: B) Timestamp ordering


Explanation: Timestamp ordering is a concurrency control mechanism to ensure serializable
schedules.

13. What is deadlock?

A) When one transaction rolls back


B) When two or more transactions wait indefinitely for each other’s locks
C) When all transactions commit
D) When system shuts down

Answer: B) When two or more transactions wait indefinitely for each other’s locks
Explanation: Deadlock is a common concurrency issue that must be handled.
14. Which property of a transaction ensures the database remains in a valid state?

A) Atomicity
B) Isolation
C) Consistency
D) Durability

Answer: C) Consistency
Explanation: Consistency ensures that a transaction transforms the database from one valid
state to another.

15. What is a schedule?

A) A backup plan
B) The order in which transactions are executed
C) The number of queries run
D) A system restart method

Answer: B) The order in which transactions are executed


Explanation: A schedule defines the sequence of operations from multiple transactions.

16. Which schedule is always serializable?

A) Cascading schedule
B) Strict schedule
C) Serializable schedule
D) Serial schedule

Answer: D) Serial schedule


Explanation: Serial schedules are by definition serializable.

17. What is the result of violating isolation in transactions?

A) Fast execution
B) Consistent results
C) Anomalies like dirty read or lost update
D) Lower CPU usage
Answer: C) Anomalies like dirty read or lost update
Explanation: Isolation prevents concurrent anomalies.

18. Which concurrency problem occurs when a transaction overwrites another transaction’s
changes?

A) Dirty read
B) Lost update
C) Phantom read
D) Deadlock

Answer: B) Lost update


Explanation: Lost update happens when two transactions read the same data and update it
without awareness of each other.

19. What does a timestamp in timestamp-ordering protocol represent?

A) Time when the data was accessed


B) Order in which transactions arrive
C) Age of the system
D) Duration of transaction

Answer: B) Order in which transactions arrive


Explanation: Timestamps help in ordering transactions to ensure serializability.

20. What is the 2-phase commit protocol used for?

A) Backup data
B) Recover from crashes
C) Ensure atomic commit in distributed systems
D) Increase redundancy

Answer: C) Ensure atomic commit in distributed systems


Explanation: 2-phase commit is a protocol used to coordinate a transaction across multiple
systems.

Key Takeaways:
 ACID properties define transaction correctness.

 Concurrency control prevents anomalies like lost update, dirty read, and deadlock.

 Locking, timestamp ordering, and 2-phase commit are essential techniques.

 2PL and serial schedules help maintain consistency and isolation.

Topic:- SQL Query

1. Which SQL statement is used to extract data from a database?

A) GET
B) OPEN
C) SELECT
D) EXTRACT

Answer: C) SELECT
Explanation: SELECT is used to retrieve data from a table.

2. What does the WHERE clause do in a SQL statement?

A) Groups the results


B) Filters the records
C) Orders the records
D) Deletes data

Answer: B) Filters the records


Explanation: WHERE filters records that meet specific conditions.

3. What is the correct SQL syntax to retrieve all columns from a table named Employees?

A) SELECT * FROM Employees;


B) GET ALL FROM Employees;
C) SHOW ALL FROM Employees;
D) SELECT ALL Employees;

Answer: A) SELECT * FROM Employees;


Explanation: * selects all columns.
4. Which SQL clause is used to remove duplicate rows from the result?

A) UNIQUE
B) NO DUPLICATE
C) DISTINCT
D) REMOVE

Answer: C) DISTINCT
Explanation: DISTINCT eliminates duplicate values.

5. What is the use of the ORDER BY clause?

A) To insert data
B) To update data
C) To delete data
D) To sort the result

Answer: D) To sort the result


Explanation: ORDER BY arranges rows in ascending or descending order.

6. Which SQL command is used to insert data into a table?

A) APPEND
B) INSERT INTO
C) ADD RECORD
D) PUT

Answer: B) INSERT INTO


Explanation: INSERT INTO table_name VALUES (...) adds data to a table.

7. What keyword is used to modify data in a table?

A) MODIFY
B) CHANGE
C) ALTER
D) UPDATE

Answer: D) UPDATE
Explanation: UPDATE changes existing records in a table.
8. Which of the following SQL statements will delete all rows in a table without deleting the
table?

A) DELETE * FROM table;


B) ERASE FROM table;
C) DELETE FROM table;
D) REMOVE table;

Answer: C) DELETE FROM table;


Explanation: Deletes all rows but retains table structure.

9. What is the correct syntax of the SQL JOIN to combine rows from two or more tables?

A) SELECT ... FROM table1 AND table2;


B) SELECT ... FROM table1 JOIN table2 ON condition;
C) SELECT ... FROM table1, table2;
D) SELECT ... MERGE table1 WITH table2;

Answer: B) SELECT ... FROM table1 JOIN table2 ON condition;


Explanation: The JOIN clause is used to combine rows based on a related column.

10. Which JOIN returns all records from both tables when there is a match or not?

A) INNER JOIN
B) LEFT JOIN
C) RIGHT JOIN
D) FULL OUTER JOIN

Answer: D) FULL OUTER JOIN


Explanation: Returns all rows when there's a match in one of the tables.

11. What function is used to count rows in SQL?

A) SUM()
B) TOTAL()
C) COUNT()
D) LENGTH()
Answer: C) COUNT(*)
Explanation: COUNT(*) returns total number of rows.

12. Which SQL clause is used with aggregate functions to group results?

A) GROUP BY
B) ORDER BY
C) WHERE
D) UNION

Answer: A) GROUP BY
Explanation: Used to group data based on one or more columns.

13. Which of the following is an aggregate function?

A) SELECT
B) WHERE
C) SUM
D) JOIN

Answer: C) SUM
Explanation: SUM, AVG, MAX, MIN, and COUNT are aggregate functions.

14. What will SELECT AVG(salary) FROM Employees; return?

A) Minimum salary
B) Maximum salary
C) Total salary
D) Average salary

Answer: D) Average salary


Explanation: AVG() computes average of numeric values.

15. What is a subquery in SQL?

A) A secondary database
B) A comment
C) A query inside another query
D) A join query

Answer: C) A query inside another query


Explanation: A subquery returns data used by the outer query.

16. Which clause is used to filter rows after grouping?

A) WHERE
B) FILTER
C) HAVING
D) GROUP

Answer: C) HAVING
Explanation: HAVING filters group results (unlike WHERE).

17. The LIKE operator is used for:

A) Exact match
B) Wildcard search
C) Sorting
D) Deleting

Answer: B) Wildcard search


Explanation: LIKE allows pattern matching with % and _.

18. What does % in LIKE '%abc%' mean?

A) Match a single character


B) Match nothing
C) Match zero or more characters
D) End of string

Answer: C) Match zero or more characters


Explanation: % matches any sequence of characters.

19. Which operator is used to combine the results of two SELECT queries?
A) AND
B) INTERSECT
C) UNION
D) JOIN

Answer: C) UNION
Explanation: UNION merges results and removes duplicates.

20. What will happen if a subquery returns more than one row in a context that expects only
one?

A) Executes normally
B) Raises error
C) Returns null
D) Skips subquery

Answer: B) Raises error


Explanation: A subquery must return a single value for comparison operators.

Key Takeaways:

 Practice the usage of SELECT, WHERE, JOIN, GROUP BY, HAVING, subqueries, and
aggregate functions.

 Focus on the differences between WHERE and HAVING.

 Understand JOIN types and common SQL errors.

1.

Table: Employees

EmpID Name Salary DeptID

101 Ram 30000 1

102 Raj 25000 2

103 Ravi 35000 1

Q: What is the result of this query?

sql
CopyEdit

SELECT AVG(Salary) FROM Employees WHERE DeptID = 1;

A) 32500
B) 30000
C) 35000
D) 27500

Answer: A) 32500
Explanation: Average of 30000 and 35000 = (30000+35000)/2 = 32500

2.

sql

CopyEdit

SELECT COUNT(*) FROM Employees WHERE Salary > 28000;

Answer: 2
Explanation: Ram (30000) and Ravi (35000) > 28000

3.

sql

CopyEdit

SELECT SUM(Salary) FROM Employees;

A) 85000
B) 90000
C) 95000
D) 80000

Answer: B) 90000
Explanation: 30000 + 25000 + 35000 = 90000

4.

If the table has 10 employees and this query returns 4:


sql

CopyEdit

SELECT COUNT(*) FROM Employees WHERE Salary < 20000;

How many employees have salary ≥ 20000?


A) 4
B) 6
C) 10
D) Cannot determine

Answer: B) 6
Explanation: 10 – 4 = 6

5.

sql

CopyEdit

SELECT MAX(Salary) FROM Employees;

Answer: 35000
Explanation: Highest salary is 35000

6.

sql

CopyEdit

SELECT MIN(Salary) FROM Employees;

Answer: 25000
Explanation: Lowest salary is 25000

7.

sql

CopyEdit
SELECT COUNT(DISTINCT DeptID) FROM Employees;

Answer: 2
Explanation: DeptID values = 1 and 2

8.

Assume a table Sales with daily sales:

Date Amount

2024-05-01 500

2024-05-02 600

2024-05-03 700

sql

CopyEdit

SELECT AVG(Amount) FROM Sales;

Answer: 600
Explanation: (500+600+700)/3 = 1800/3 = 600

9.

sql

CopyEdit

SELECT SUM(Amount) FROM Sales WHERE Date BETWEEN '2024-05-01' AND '2024-05-02';

Answer: 1100
Explanation: 500 + 600

10.

In a Marks table with:


Name Marks

A 80

B 75

C 90

sql

CopyEdit

SELECT COUNT(*) FROM Marks WHERE Marks > 80;

Answer: 1
Explanation: Only C has marks > 80

11.

What will the following query return?

sql

CopyEdit

SELECT ROUND(AVG(Marks)) FROM Marks;

Answer: 82
Explanation: (80+75+90)/3 = 81.66 ≈ 82

12.

Assume:

sql

CopyEdit

SELECT SUM(Marks)%3 FROM Marks;

Answer: 245 % 3 = 2
Explanation: 80+75+90 = 245 → 245 % 3 = 2
13.

If:

sql

CopyEdit

SELECT COUNT(*) FROM Marks WHERE Marks BETWEEN 75 AND 90;

Answer: 3
Explanation: All students in range 75–90

14.

sql

CopyEdit

SELECT COUNT(*) FROM Marks WHERE Name LIKE 'A%';

Answer: 1
Explanation: Only one name starts with A

15.

If table Products has prices: 100, 150, 200, 250

sql

CopyEdit

SELECT AVG(Price) FROM Products WHERE Price > 100;

Answer: (150+200+250)/3 = 600/3 = 200

16.

sql

CopyEdit

SELECT Price*0.10 AS Discount FROM Products WHERE Price = 200;


Answer: 20
Explanation: 10% of 200 = 20

17.

If we update Price = Price * 2 where Price < 200, what will be the new price of 150?
Answer: 300

18.

If there are 5 rows and this query returns 3:

sql

CopyEdit

SELECT COUNT(*) FROM Students WHERE Marks >= 50;

How many students scored below 50?


Answer: 2

19.

Given:

EmpID Salary Bonus

1 30000 5000

2 25000 4000

sql

CopyEdit

SELECT Salary + Bonus FROM Employees;

Answer:
1 → 35000
2 → 29000
20.

What is the output of:

sql

CopyEdit

SELECT LENGTH('Computer') + LENGTH('Science');

A) 14
B) 15
C) 16
D) 17

Answer: D) 17
Explanation: 8 (Computer) + 9 (Science) = 17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy