Databases & DBMS MCQs
20 practice MCQs on this page Page 8 of 16
Tap an option to check your answer — the correct answer and full explanation appear after you choose.
Computer ScienceDatabases & DBMS PPSCID: LTP-7749
A LEFT JOIN returns all rows from the left table and:
- AOnly rows that match in both tables
- BMatching rows from the right table, with NULL where there is no match ✓ Correct answer
- CNo rows from the right table
- DAll rows from the right table only
✓ Correct answer: Matching rows from the right table, with NULL where there is no match
Full explanation
A LEFT JOIN returns all rows from the left table and matching rows from the right table, with NULL where there is no match.
Computer ScienceDatabases & DBMS PPSCID: LTP-7750
A RIGHT JOIN returns all rows from the right table and:
- AOnly rows that match in both tables
- BNo rows from the left table
- CMatching rows from the left table, with NULL where there is no match ✓ Correct answer
- DAll rows from the left table only
✓ Correct answer: Matching rows from the left table, with NULL where there is no match
Full explanation
A RIGHT JOIN returns all rows from the right table and matching rows from the left table, with NULL where there is no match.
Computer ScienceDatabases & DBMS PPSCID: LTP-7751
A FULL OUTER JOIN returns:
- AOnly matching rows
- BOnly the left table rows
- COnly the right table rows
- DAll rows from both tables, with NULL where there is no match ✓ Correct answer
✓ Correct answer: All rows from both tables, with NULL where there is no match
Full explanation
A FULL OUTER JOIN returns all rows from both tables, with NULL where there is no match on either side.
Computer ScienceDatabases & DBMS PPSCID: LTP-7752
A CROSS JOIN between two tables produces:
- AThe Cartesian product of the two tables ✓ Correct answer
- BOnly matching rows
- CAn empty result
- DA single row
✓ Correct answer: The Cartesian product of the two tables
Full explanation
A CROSS JOIN produces the Cartesian product of the two tables, pairing every row of one table with every row of the other.
Computer ScienceDatabases & DBMS PPSCID: LTP-7753
In SQL, the UNION operator combines the results of two queries and:
- AKeeps all duplicate rows
- BRemoves duplicate rows ✓ Correct answer
- CDeletes the tables
- DSorts by the primary key only
✓ Correct answer: Removes duplicate rows
Full explanation
The UNION operator combines two query results and removes duplicate rows, while UNION ALL would keep them.
Computer ScienceDatabases & DBMS PPSCID: LTP-7754
In SQL, the GROUP BY clause is used to:
- ASort rows in reverse order
- BDelete duplicate tables
- CGroup rows that share the same values for aggregate functions ✓ Correct answer
- DCreate a new database
✓ Correct answer: Group rows that share the same values for aggregate functions
Full explanation
The GROUP BY clause is used to group rows that share the same values for aggregate functions, so each group can be summarised separately.
Computer ScienceDatabases & DBMS PPSCID: LTP-7755
In SQL, the HAVING clause differs from WHERE because HAVING filters:
- ARows before grouping
- BTables before creation
- CColumns by data type
- DGroups after aggregation ✓ Correct answer
✓ Correct answer: Groups after aggregation
Full explanation
The HAVING clause filters groups after aggregation, while WHERE filters individual rows before grouping.
Computer ScienceDatabases & DBMS PPSCID: LTP-7756
In SQL, the ORDER BY clause is used to:
- ASort the result rows ✓ Correct answer
- BDelete rows
- CCreate an index
- DGrant permissions
✓ Correct answer: Sort the result rows
Full explanation
The ORDER BY clause is used to sort the result rows, in ascending order by default or descending with DESC.
Computer ScienceDatabases & DBMS PPSCID: LTP-7757
In SQL, the DISTINCT keyword is used to:
- ADelete a table
- BRemove duplicate values from the result ✓ Correct answer
- CSort by date
- DAdd a new column
✓ Correct answer: Remove duplicate values from the result
Full explanation
The DISTINCT keyword is used to remove duplicate values from the result, so each value appears only once.
Computer ScienceDatabases & DBMS PPSCID: LTP-7758
Which SQL aggregate function returns the number of rows in a group?
- ASUM
- BAVG
- CCOUNT ✓ Correct answer
- DMAX
✓ Correct answer: COUNT
Full explanation
The COUNT aggregate function returns the number of rows in a group, while SUM adds values and AVG finds the average.
Computer ScienceDatabases & DBMS PPSCID: LTP-7759
A database view is best described as:
- AA physical copy of a table
- BA backup file
- CA user password
- DA virtual table based on a query ✓ Correct answer
✓ Correct answer: A virtual table based on a query
Full explanation
A database view is a virtual table based on a query, showing data from one or more tables without storing it separately.
Computer ScienceDatabases & DBMS PPSCID: LTP-7760
A database index is mainly used to:
- ASpeed up data retrieval ✓ Correct answer
- BSlow down queries
- CDelete records
- DEncrypt passwords
✓ Correct answer: Speed up data retrieval
Full explanation
A database index is mainly used to speed up data retrieval by letting the system find rows quickly without scanning the whole table.
Computer ScienceDatabases & DBMS PPSCID: LTP-7761
A trigger in a database is:
- AA printed report
- BA stored procedure that runs automatically when an event occurs ✓ Correct answer
- CA type of virus
- DA backup tape
✓ Correct answer: A stored procedure that runs automatically when an event occurs
Full explanation
A trigger is a stored procedure that runs automatically when an event occurs, such as inserting or updating a row.
Computer ScienceDatabases & DBMS PPSCID: LTP-7762
A stored procedure is best described as:
- AA single row of a table
- BA user manual
- CA set of SQL statements saved in the database for reuse ✓ Correct answer
- DA network cable
✓ Correct answer: A set of SQL statements saved in the database for reuse
Full explanation
A stored procedure is a set of SQL statements saved in the database for reuse, executed by calling its name.
Computer ScienceDatabases & DBMS PPSCID: LTP-7763
In an ER diagram, cardinality describes:
- AThe size of the database file
- BThe speed of the server
- CThe colour of the diagram
- DHow many instances of one entity relate to another ✓ Correct answer
✓ Correct answer: How many instances of one entity relate to another
Full explanation
Cardinality describes how many instances of one entity relate to another, such as one-to-many or many-to-many.
Computer ScienceDatabases & DBMS PPSCID: LTP-7764
A weak entity in an ER model is an entity that:
- ACannot exist without its owner entity ✓ Correct answer
- BHas no attributes at all
- CIs never stored
- DHas many primary keys
✓ Correct answer: Cannot exist without its owner entity
Full explanation
A weak entity cannot exist without its owner entity, such as a dependent of an employee, and it has no key of its own.
Computer ScienceDatabases & DBMS PPSCID: LTP-7765
The schema of a database describes:
- AThe data stored in the tables
- BThe structure of the database, including tables and columns ✓ Correct answer
- CThe password of the DBA
- DThe speed of queries
✓ Correct answer: The structure of the database, including tables and columns
Full explanation
The schema describes the structure of the database, including tables and columns and their relationships.
Computer ScienceDatabases & DBMS PPSCID: LTP-7766
The data dictionary of a DBMS contains:
- AThe personal data of users
- BPrinted manuals
- CMetadata about the database structure ✓ Correct answer
- DBackup tapes only
✓ Correct answer: Metadata about the database structure
Full explanation
The data dictionary contains metadata about the database structure, such as table definitions and column types.
Computer ScienceDatabases & DBMS PPSCID: LTP-7767
Which of the following is the main responsibility of a Database Administrator (DBA)?
- AWriting web pages
- BDesigning logos
- CRepairing printers
- DManaging and securing the database system ✓ Correct answer
✓ Correct answer: Managing and securing the database system
Full explanation
A Database Administrator is responsible for managing and securing the database system, including backups and user access.
Computer ScienceDatabases & DBMS PPSCID: LTP-7768
In a database, concurrency control is needed mainly to:
- APrevent conflicts when several users access data at the same time ✓ Correct answer
- BDelete old records
- CPrint reports faster
- DCompress the database file
✓ Correct answer: Prevent conflicts when several users access data at the same time
Full explanation
Concurrency control is needed to prevent conflicts when several users access data at the same time, keeping the database consistent.
Practice these MCQs interactively
← Computer Science MCQs