Question	Option A	Option B	Option C	Option D	Answer	Solution	Subject	Category	Topic	Difficulty	Type	Tags	Image	Solution Image	Audio	Solution Audio
According to Eric Brewer's CAP theorem, what trade-off must any distributed data store make during an unavoidable network partition (P)?	It must automatically reboot all replica nodes to clear partition state.	It must choose between maintaining strict Consistency (C) or maintaining Availability (A).	It must sacrifice Persistence (P) to preserve Atomicity and Durability.	It must choose between Data Compression (C) or Auditability (A).	B	Because network partitions are physically inevitable in distributed networks, systems must trade off consistency against availability.	Databases	Beyond Relational	CAP theorem	Intermediate	Elements	computing, databases, beyond-relational, cap-theorem				
What does the BASE consistency model stand for as an alternative to ACID in distributed NoSQL databases?	Binary Access, Synchronous Execution, Atomic Durability.	Broad Availability, Scalable Encryption, Distributed Transactions.	Bounded Allocation, Shared-nothing Storage, Elasticity.	Basically Available, Soft state, Eventual consistency.	D	BASE prioritizes availability over immediate consistency, relaxing strict ACID guarantees to support horizontal scalability.	Databases	Beyond Relational	CAP theorem	Intermediate	Elements	computing, databases, beyond-relational, cap-theorem				
According to Eric Brewer's CAP theorem, what trade-off must any distributed data store make during an unavoidable network partition (P)?	It must automatically reboot all replica nodes to clear partition state.	It must choose between maintaining strict Consistency (C) or maintaining Availability (A).	It must sacrifice Persistence (P) to preserve Atomicity and Durability.	It must choose between Data Compression (C) or Auditability (A).	B	Because network partitions are physically inevitable in distributed networks, systems must trade off consistency against availability.	Databases	Beyond Relational	CAP theorem	Intermediate	Elements	computing, databases, beyond-relational, cap-theorem				
What does the BASE consistency model stand for as an alternative to ACID in distributed NoSQL databases?	Binary Access, Synchronous Execution, Atomic Durability.	Broad Availability, Scalable Encryption, Distributed Transactions.	Bounded Allocation, Shared-nothing Storage, Elasticity.	Basically Available, Soft state, Eventual consistency.	D	BASE prioritizes availability over immediate consistency, relaxing strict ACID guarantees to support horizontal scalability.	Databases	Beyond Relational	CAP theorem	Intermediate	Elements	computing, databases, beyond-relational, cap-theorem				
How do Online Transaction Processing (OLTP) and Online Analytical Processing (OLAP) database workloads fundamentally differ?	OLTP focuses on fast, atomic read/write updates on few rows; OLAP focuses on complex historical aggregations over millions of rows.	OLTP uses columnar disk layouts exclusively; OLAP uses row-based memory buffers only.	OLTP stores historical analytical summaries; OLAP processes real-time shopping cart checkout transactions.	OLTP operates on distributed cloud clusters; OLAP is restricted to single-node embedded devices.	A	OLTP emphasizes write throughput, concurrency, and normalized integrity; OLAP emphasizes read aggregations, denormalization, and columnar scans.	Databases	Beyond Relational	Data warehousing	Intermediate	Elements	computing, databases, beyond-relational, data-warehousing				
What is the functional purpose of the Extract, Transform, Load (ETL) pipeline in enterprise data architecture?	To compress relational database backup files before uploading them to cold storage.	To encrypt client-server TCP packets transmitted across local area networks.	To automatically normalize document database collections into Sixth Normal Form.	To ingest data from multiple disparate transactional operational systems, cleanse and conform it, and load it into a central data warehouse.	D	ETL consolidates, transforms, and standardizes data across multiple operational sources into an integrated analytical schema.	Databases	Beyond Relational	Data warehousing	Intermediate	Elements	computing, databases, beyond-relational, data-warehousing				
How do Online Transaction Processing (OLTP) and Online Analytical Processing (OLAP) database workloads fundamentally differ?	OLTP focuses on fast, atomic read/write updates on few rows; OLAP focuses on complex historical aggregations over millions of rows.	OLTP uses columnar disk layouts exclusively; OLAP uses row-based memory buffers only.	OLTP stores historical analytical summaries; OLAP processes real-time shopping cart checkout transactions.	OLTP operates on distributed cloud clusters; OLAP is restricted to single-node embedded devices.	A	OLTP emphasizes write throughput, concurrency, and normalized integrity; OLAP emphasizes read aggregations, denormalization, and columnar scans.	Databases	Beyond Relational	Data warehousing	Intermediate	Elements	computing, databases, beyond-relational, data-warehousing				
What is the functional purpose of the Extract, Transform, Load (ETL) pipeline in enterprise data architecture?	To compress relational database backup files before uploading them to cold storage.	To encrypt client-server TCP packets transmitted across local area networks.	To automatically normalize document database collections into Sixth Normal Form.	To ingest data from multiple disparate transactional operational systems, cleanse and conform it, and load it into a central data warehouse.	D	ETL consolidates, transforms, and standardizes data across multiple operational sources into an integrated analytical schema.	Databases	Beyond Relational	Data warehousing	Intermediate	Elements	computing, databases, beyond-relational, data-warehousing				
What security doctrine dictates that database accounts and applications should possess only the absolute minimum permissions needed to perform their tasks?	Principle of Least Privilege.	Kerberos mutual authentication.	Defense-in-depth perimeter routing.	Zero-knowledge proof validation.	A	Least privilege minimizes blast radius: a compromised application account cannot drop tables or access unauthorized confidential columns.	Databases	Beyond Relational	Database security	Intermediate	Elements	computing, databases, beyond-relational, database-security				
Which software development practice provides the most reliable protection against SQL injection attacks?	Restricting database access exclusively to local loopback 127.0.0.1 IP addresses.	Running the database server process under root or administrator privileges.	Filtering user inputs by searching for and stripping single quotation marks.	Using parameterized queries (prepared statements) with bound variables for all user inputs.	D	Parameterized queries send SQL templates and user parameters separately, preventing input strings from altering query parse trees.	Databases	Beyond Relational	Database security	Intermediate	Elements	computing, databases, beyond-relational, database-security				
What security doctrine dictates that database accounts and applications should possess only the absolute minimum permissions needed to perform their tasks?	Principle of Least Privilege.	Kerberos mutual authentication.	Defense-in-depth perimeter routing.	Zero-knowledge proof validation.	A	Least privilege minimizes blast radius: a compromised application account cannot drop tables or access unauthorized confidential columns.	Databases	Beyond Relational	Database security	Intermediate	Elements	computing, databases, beyond-relational, database-security				
Which software development practice provides the most reliable protection against SQL injection attacks?	Restricting database access exclusively to local loopback 127.0.0.1 IP addresses.	Running the database server process under root or administrator privileges.	Filtering user inputs by searching for and stripping single quotation marks.	Using parameterized queries (prepared statements) with bound variables for all user inputs.	D	Parameterized queries send SQL templates and user parameters separately, preventing input strings from altering query parse trees.	Databases	Beyond Relational	Database security	Intermediate	Elements	computing, databases, beyond-relational, database-security				
What architectural capability distinguishes a document store (e.g. MongoDB) from a pure key-value store (e.g. Redis)?	Document stores do not support unique identifiers or primary keys.	Document stores treat stored values as completely opaque binary blobs.	Document stores parse structured documents (JSON/BSON), allowing secondary indexing and querying on internal nested fields.	Document stores are restricted to running entirely within in-memory caches.	C	Key-value stores retrieve values only by primary key; document stores inspect and index internal document attributes and nested arrays.	Databases	Beyond Relational	Document and key-value stores	Intermediate	Elements	computing, databases, beyond-relational, document-and-key-value-stores				
For which architectural task is an in-memory key-value database such as Redis most commonly utilized?	Caching frequently read data, tracking session state, and maintaining distributed real-time counters.	Executing multi-hour historical analytical aggregations on terabyte datasets.	Enforcing complex recursive foreign key integrity across hundreds of tables.	Replacing file systems for high-resolution uncompressed satellite imagery.	A	Redis keeps datasets in RAM, delivering sub-millisecond read/write latency ideal for caches, sessions, rate limiters, and message brokers.	Databases	Beyond Relational	Document and key-value stores	Intermediate	Elements	computing, databases, beyond-relational, document-and-key-value-stores				
What architectural capability distinguishes a document store (e.g. MongoDB) from a pure key-value store (e.g. Redis)?	Document stores do not support unique identifiers or primary keys.	Document stores treat stored values as completely opaque binary blobs.	Document stores parse structured documents (JSON/BSON), allowing secondary indexing and querying on internal nested fields.	Document stores are restricted to running entirely within in-memory caches.	C	Key-value stores retrieve values only by primary key; document stores inspect and index internal document attributes and nested arrays.	Databases	Beyond Relational	Document and key-value stores	Intermediate	Elements	computing, databases, beyond-relational, document-and-key-value-stores				
For which architectural task is an in-memory key-value database such as Redis most commonly utilized?	Caching frequently read data, tracking session state, and maintaining distributed real-time counters.	Executing multi-hour historical analytical aggregations on terabyte datasets.	Enforcing complex recursive foreign key integrity across hundreds of tables.	Replacing file systems for high-resolution uncompressed satellite imagery.	A	Redis keeps datasets in RAM, delivering sub-millisecond read/write latency ideal for caches, sessions, rate limiters, and message brokers.	Databases	Beyond Relational	Document and key-value stores	Intermediate	Elements	computing, databases, beyond-relational, document-and-key-value-stores				
What is the fundamental engineering performance trade-off associated with creating multiple secondary indexes on a database table?	Elimination of all disk I/O at the expense of increased CPU register contention.	Faster write throughput at the expense of slower read query lookups.	Faster read query lookups at the expense of slower write throughput and increased storage consumption.	Guaranteed transactional isolation at the expense of foreign key validation.	C	Each insert, update, or delete must update all secondary index trees on disk, adding I/O overhead while accelerating reads.	Databases	Beyond Relational	Indexing	Intermediate	Elements	computing, databases, beyond-relational, indexing				
When is a Bitmap Index substantially more efficient than a traditional B-tree index in data warehousing?	For highly volatile transactional OLTP tables with hundreds of concurrent writes per second.	For primary key columns where every row stores a distinct sequential integer.	For low-cardinality columns (such as gender or region) evaluated using multi-attribute boolean AND/OR queries.	For large binary media files undergoing frequent streaming updates.	C	Bitmap indexes store bit vectors per distinct value, enabling bitwise operations (AND, OR) for low-cardinality analytical queries.	Databases	Beyond Relational	Indexing	Intermediate	Elements	computing, databases, beyond-relational, indexing				
What is the fundamental engineering performance trade-off associated with creating multiple secondary indexes on a database table?	Elimination of all disk I/O at the expense of increased CPU register contention.	Faster read query lookups at the expense of slower write throughput and increased storage consumption.	Faster write throughput at the expense of slower read query lookups.	Guaranteed transactional isolation at the expense of foreign key validation.	B	Each insert, update, or delete must update all secondary index trees on disk, adding I/O overhead while accelerating reads.	Databases	Beyond Relational	Indexing	Intermediate	Elements	computing, databases, beyond-relational, indexing				
When is a Bitmap Index substantially more efficient than a traditional B-tree index in data warehousing?	For highly volatile transactional OLTP tables with hundreds of concurrent writes per second.	For low-cardinality columns (such as gender or region) evaluated using multi-attribute boolean AND/OR queries.	For primary key columns where every row stores a distinct sequential integer.	For large binary media files undergoing frequent streaming updates.	B	Bitmap indexes store bit vectors per distinct value, enabling bitwise operations (AND, OR) for low-cardinality analytical queries.	Databases	Beyond Relational	Indexing	Intermediate	Elements	computing, databases, beyond-relational, indexing				
Which set represents the four primary architectural data models encompassing NoSQL database systems?	Key-value, document, wide-column (column-family), and graph databases.	Relational, hierarchical, network, and spreadsheet databases.	Object-oriented, spatial, temporal, and deductive databases.	Flat file, CSV, XML, and JSON databases.	A	NoSQL categories are classified by data model: key-value (Redis), document (MongoDB), wide-column (Cassandra), and graph (Neo4j).	Databases	Beyond Relational	NoSQL types	Intermediate	Elements	computing, databases, beyond-relational, nosql-types				
For which application architecture is a native graph database (such as Neo4j) strictly preferred over a relational database?	Storing tabular time-series sensor data arriving at fixed one-second intervals.	Executing high-throughput bulk numerical payroll computations with zero joins.	Navigating densely connected, multi-hop relationship paths such as social network friends or recommendation engines.	Storing unstructured image and video media blobs on magnetic tape.	C	Graph databases use index-free adjacency where nodes directly point to neighbors, avoiding expensive multi-table recursive relational joins.	Databases	Beyond Relational	NoSQL types	Intermediate	Elements	computing, databases, beyond-relational, nosql-types				
Which set represents the four primary architectural data models encompassing NoSQL database systems?	Flat file, CSV, XML, and JSON databases.	Relational, hierarchical, network, and spreadsheet databases.	Object-oriented, spatial, temporal, and deductive databases.	Key-value, document, wide-column (column-family), and graph databases.	D	NoSQL categories are classified by data model: key-value (Redis), document (MongoDB), wide-column (Cassandra), and graph (Neo4j).	Databases	Beyond Relational	NoSQL types	Intermediate	Elements	computing, databases, beyond-relational, nosql-types				
For which application architecture is a native graph database (such as Neo4j) strictly preferred over a relational database?	Storing tabular time-series sensor data arriving at fixed one-second intervals.	Executing high-throughput bulk numerical payroll computations with zero joins.	Storing unstructured image and video media blobs on magnetic tape.	Navigating densely connected, multi-hop relationship paths such as social network friends or recommendation engines.	D	Graph databases use index-free adjacency where nodes directly point to neighbors, avoiding expensive multi-table recursive relational joins.	Databases	Beyond Relational	NoSQL types	Intermediate	Elements	computing, databases, beyond-relational, nosql-types				
What is the core architectural difference between database replication and database sharding?	Replication stores data in cloud storage; sharding stores data in local memory caches.	Replication partitions tables vertically; sharding duplicates all tables on every machine.	Replication copies identical data across nodes for high availability; sharding partitions data horizontally across nodes for scale.	Replication is used exclusively for graph databases; sharding is used for relational databases.	C	Replication provides redundancy and scales reads; sharding distributes data subsets across servers to scale write capacity and storage.	Databases	Beyond Relational	Replication and sharding	Intermediate	Elements	computing, databases, beyond-relational, replication-and-sharding				
What is the operational drawback of synchronous replication compared to asynchronous replication in distributed database clusters?	Increased risk of data loss during an unexpected primary node crash.	Higher write latency, because write operations must wait for confirmation from replica nodes before completing.	Inability of secondary nodes to serve read requests under any circumstance.	Automatic corruption of relational schema foreign key definitions.	B	Synchronous replication blocks write acknowledgement until secondary nodes persist data, adding network latency to client writes.	Databases	Beyond Relational	Replication and sharding	Intermediate	Elements	computing, databases, beyond-relational, replication-and-sharding				
What is the core architectural difference between database replication and database sharding?	Replication stores data in cloud storage; sharding stores data in local memory caches.	Replication copies identical data across nodes for high availability; sharding partitions data horizontally across nodes for scale.	Replication partitions tables vertically; sharding duplicates all tables on every machine.	Replication is used exclusively for graph databases; sharding is used for relational databases.	B	Replication provides redundancy and scales reads; sharding distributes data subsets across servers to scale write capacity and storage.	Databases	Beyond Relational	Replication and sharding	Intermediate	Elements	computing, databases, beyond-relational, replication-and-sharding				
What is the operational drawback of synchronous replication compared to asynchronous replication in distributed database clusters?	Increased risk of data loss during an unexpected primary node crash.	Higher write latency, because write operations must wait for confirmation from replica nodes before completing.	Inability of secondary nodes to serve read requests under any circumstance.	Automatic corruption of relational schema foreign key definitions.	B	Synchronous replication blocks write acknowledgement until secondary nodes persist data, adding network latency to client writes.	Databases	Beyond Relational	Replication and sharding	Intermediate	Elements	computing, databases, beyond-relational, replication-and-sharding				
What constitutes the primary architectural characteristic of SQLite compared to client-server RDBMS engines like PostgreSQL or MySQL?	SQLite stores tables in separate cloud buckets managed by an external hypervisor.	SQLite requires a dedicated background daemon process listening on TCP port 3306.	SQLite is serverless and in-process, reading and writing directly to a single cross-platform disk file.	SQLite cannot execute standard SQL SELECT, INSERT, or JOIN statements.	C	SQLite links directly into the host application code, operating with zero server configuration and storing the complete database in one file.	Databases	Beyond Relational	SQLite and embedded databases	Intermediate	Elements	computing, databases, beyond-relational, sqlite-and-embedded-databases				
What significant operational constraint or risk governs SQLite in traditional rollback journal mode?	Only one writer can update the database file at any given moment, locking out concurrent readers.	The database engine crashes if two threads issue SELECT statements simultaneously.	Concurrent transactions can never access the same primary key in read-only mode.	Tables must be manually unlocked by restarting the host operating system.	A	In rollback journal mode, an exclusive lock is required for writes, blocking concurrent readers and serializing all writes.	Databases	Beyond Relational	SQLite and embedded databases	Intermediate	Elements	computing, databases, beyond-relational, sqlite-and-embedded-databases				
What constitutes the primary architectural characteristic of SQLite compared to client-server RDBMS engines like PostgreSQL or MySQL?	SQLite stores tables in separate cloud buckets managed by an external hypervisor.	SQLite requires a dedicated background daemon process listening on TCP port 3306.	SQLite cannot execute standard SQL SELECT, INSERT, or JOIN statements.	SQLite is serverless and in-process, reading and writing directly to a single cross-platform disk file.	D	SQLite links directly into the host application code, operating with zero server configuration and storing the complete database in one file.	Databases	Beyond Relational	SQLite and embedded databases	Intermediate	Elements	computing, databases, beyond-relational, sqlite-and-embedded-databases				
What significant operational constraint or risk governs SQLite in traditional rollback journal mode?	Only one writer can update the database file at any given moment, locking out concurrent readers.	The database engine crashes if two threads issue SELECT statements simultaneously.	Concurrent transactions can never access the same primary key in read-only mode.	Tables must be manually unlocked by restarting the host operating system.	A	In rollback journal mode, an exclusive lock is required for writes, blocking concurrent readers and serializing all writes.	Databases	Beyond Relational	SQLite and embedded databases	Intermediate	Elements	computing, databases, beyond-relational, sqlite-and-embedded-databases				
Which property of the classic ACID transaction model guarantees that once a transaction commits, its state changes survive subsequent power outages or crashes?	Atomicity.	Consistency.	Durability.	Isolation.	C	Durability ensures committed transaction effects persist in non-volatile storage, maintained via write-ahead logging (WAL) and disk flushes.	Databases	Beyond Relational	Transactions and ACID	Intermediate	Elements	computing, databases, beyond-relational, transactions-and-acid				
How does Write-Ahead Logging (WAL) uphold the Durability guarantee in relational database management systems?	Log records are encrypted with public keys and sent to cold cloud storage once per week.	Log records describing changes are written to non-volatile disk storage before corresponding dirty data pages are flushed.	Database tables are completely duplicated into memory before every write statement.	The database delays all read queries until write transactions finish execution.	B	WAL guarantees that crash recovery algorithms can redo committed changes even if unwritten dirty buffer pages in RAM were lost during failure.	Databases	Beyond Relational	Transactions and ACID	Intermediate	Elements	computing, databases, beyond-relational, transactions-and-acid				
Which property of the classic ACID transaction model guarantees that once a transaction commits, its state changes survive subsequent power outages or crashes?	Atomicity.	Consistency.	Durability.	Isolation.	C	Durability ensures committed transaction effects persist in non-volatile storage, maintained via write-ahead logging (WAL) and disk flushes.	Databases	Beyond Relational	Transactions and ACID	Intermediate	Elements	computing, databases, beyond-relational, transactions-and-acid				
How does Write-Ahead Logging (WAL) uphold the Durability guarantee in relational database management systems?	Log records are encrypted with public keys and sent to cold cloud storage once per week.	Log records describing changes are written to non-volatile disk storage before corresponding dirty data pages are flushed.	Database tables are completely duplicated into memory before every write statement.	The database delays all read queries until write transactions finish execution.	B	WAL guarantees that crash recovery algorithms can redo committed changes even if unwritten dirty buffer pages in RAM were lost during failure.	Databases	Beyond Relational	Transactions and ACID	Intermediate	Elements	computing, databases, beyond-relational, transactions-and-acid				
How does a Differential Backup fundamentally differ from an Incremental Backup in database administration?	A differential backup copies only index structures; an incremental backup copies raw table data.	A differential backup captures all changes made since the last full backup, while an incremental backup captures changes since the last backup of any type.	A differential backup must be run hourly; an incremental backup can only run once per year.	A differential backup discards transaction logs; an incremental backup encrypts transaction logs.	B	Restoring differential backups requires only the full backup plus the latest differential; restoring incremental requires all intervening increments.	Databases	Database Design and Performance	Backup and recovery	Intermediate	Elements	computing, databases, database-design-and-performance, backup-and-recovery				
In database business continuity, what metric measures the maximum allowable duration of downtime before service must be restored?	Mean Time Between Failures (MTBF).	Maximum Tolerable Latency (MTL).	Recovery Point Objective (RPO).	Recovery Time Objective (RTO).	D	RTO represents the target time elapsed between outage onset and restoration of operational database access.	Databases	Database Design and Performance	Backup and recovery	Intermediate	Elements	computing, databases, database-design-and-performance, backup-and-recovery				
How does a Differential Backup fundamentally differ from an Incremental Backup in database administration?	A differential backup copies only index structures; an incremental backup copies raw table data.	A differential backup captures all changes made since the last full backup, while an incremental backup captures changes since the last backup of any type.	A differential backup must be run hourly; an incremental backup can only run once per year.	A differential backup discards transaction logs; an incremental backup encrypts transaction logs.	B	Restoring differential backups requires only the full backup plus the latest differential; restoring incremental requires all intervening increments.	Databases	Database Design and Performance	Backup and recovery	Intermediate	Elements	computing, databases, database-design-and-performance, backup-and-recovery				
In database business continuity, what metric measures the maximum allowable duration of downtime before service must be restored?	Mean Time Between Failures (MTBF).	Maximum Tolerable Latency (MTL).	Recovery Point Objective (RPO).	Recovery Time Objective (RTO).	D	RTO represents the target time elapsed between outage onset and restoration of operational database access.	Databases	Database Design and Performance	Backup and recovery	Intermediate	Elements	computing, databases, database-design-and-performance, backup-and-recovery				
What is the foundational rule governing the Growing Phase of Two-Phase Locking (2PL)?	A transaction can only acquire locks on indexed primary key attributes.	A transaction must release all read locks before acquiring any write lock.	A transaction must acquire an exclusive lock on the entire database catalog.	A transaction may acquire new locks as needed, but is strictly prohibited from releasing any lock.	D	In 2PL, the growing phase allows lock acquisitions only; once any lock is released, the shrinking phase begins and no new locks may be acquired.	Databases	Database Design and Performance	Concurrency control	Intermediate	Elements	computing, databases, database-design-and-performance, concurrency-control				
How does Multi-Version Concurrency Control (MVCC) eliminate read-write locking contention in modern database engines?	Readers view a snapshot of older committed row versions without locking, while writers create new row versions simultaneously.	Database transactions are serialized into a single-threaded background queue.	Readers abort any concurrent writer attempting to modify the same table.	Writers queue all write modifications in temporary local text files.	A	Under MVCC, readers never block writers, and writers never block readers, because readers access timestamped immutable snapshots.	Databases	Database Design and Performance	Concurrency control	Intermediate	Elements	computing, databases, database-design-and-performance, concurrency-control				
What is the foundational rule governing the Growing Phase of Two-Phase Locking (2PL)?	A transaction can only acquire locks on indexed primary key attributes.	A transaction must release all read locks before acquiring any write lock.	A transaction must acquire an exclusive lock on the entire database catalog.	A transaction may acquire new locks as needed, but is strictly prohibited from releasing any lock.	D	In 2PL, the growing phase allows lock acquisitions only; once any lock is released, the shrinking phase begins and no new locks may be acquired.	Databases	Database Design and Performance	Concurrency control	Intermediate	Elements	computing, databases, database-design-and-performance, concurrency-control				
How does Multi-Version Concurrency Control (MVCC) eliminate read-write locking contention in modern database engines?	Readers view a snapshot of older committed row versions without locking, while writers create new row versions simultaneously.	Database transactions are serialized into a single-threaded background queue.	Readers abort any concurrent writer attempting to modify the same table.	Writers queue all write modifications in temporary local text files.	A	Under MVCC, readers never block writers, and writers never block readers, because readers access timestamped immutable snapshots.	Databases	Database Design and Performance	Concurrency control	Intermediate	Elements	computing, databases, database-design-and-performance, concurrency-control				
In mobile offline-first architectures, how does the local embedded database interact with cloud backend databases?	The mobile device sends raw TCP SQL queries across mobile cellular networks for every screen render.	The cloud backend completely deletes local mobile records upon every disconnect.	The local database acts as the single source of truth for UI rendering, synchronizing delta updates asynchronously with the cloud backend.	The mobile device stores all data unencrypted in shared temporary cache files.	C	Offline-first designs persist local changes immediately to local SQLite/Room/CoreData, queuing sync operations until network connectivity resumes.	Databases	Database Design and Performance	Data modeling for mobile apps	Intermediate	Elements	computing, databases, database-design-and-performance, data-modeling-for-mobile-apps				
Why are Universally Unique Identifiers (UUIDs) strongly preferred over auto-increment integers as primary keys in mobile offline-first applications?	UUIDs eliminate the need for index structures within embedded mobile SQLite engines.	UUIDs consume significantly less physical storage space on disk than 32-bit integers.	UUIDs are mathematically guaranteed to sort records in ascending chronological order.	Client devices can independently generate globally unique primary keys offline without coordinating with a central database server.	D	Offline clients cannot query a central sequence counter; UUIDs allow distributed client-side creation with negligible collision probability.	Databases	Database Design and Performance	Data modeling for mobile apps	Intermediate	Elements	computing, databases, database-design-and-performance, data-modeling-for-mobile-apps				
In mobile offline-first architectures, how does the local embedded database interact with cloud backend databases?	The mobile device sends raw TCP SQL queries across mobile cellular networks for every screen render.	The local database acts as the single source of truth for UI rendering, synchronizing delta updates asynchronously with the cloud backend.	The cloud backend completely deletes local mobile records upon every disconnect.	The mobile device stores all data unencrypted in shared temporary cache files.	B	Offline-first designs persist local changes immediately to local SQLite/Room/CoreData, queuing sync operations until network connectivity resumes.	Databases	Database Design and Performance	Data modeling for mobile apps	Intermediate	Elements	computing, databases, database-design-and-performance, data-modeling-for-mobile-apps				
Why are Universally Unique Identifiers (UUIDs) strongly preferred over auto-increment integers as primary keys in mobile offline-first applications?	UUIDs eliminate the need for index structures within embedded mobile SQLite engines.	Client devices can independently generate globally unique primary keys offline without coordinating with a central database server.	UUIDs are mathematically guaranteed to sort records in ascending chronological order.	UUIDs consume significantly less physical storage space on disk than 32-bit integers.	B	Offline clients cannot query a central sequence counter; UUIDs allow distributed client-side creation with negligible collision probability.	Databases	Database Design and Performance	Data modeling for mobile apps	Intermediate	Elements	computing, databases, database-design-and-performance, data-modeling-for-mobile-apps				
Which deployment strategy enables zero-downtime database schema alterations without locking production tables against active applications?	Stopping all application server instances for offline maintenance windows.	Dropping all foreign key constraints permanently from the catalog.	Expand and Contract pattern (parallel-run schema evolution).	Direct hot-patching of physical disk block headers while queries run.	C	Expand-and-contract adds new columns/tables (expand), writes to both, migrates data, transitions reads, and deletes old columns (contract).	Databases	Database Design and Performance	Database migrations	Intermediate	Elements	computing, databases, database-design-and-performance, database-migrations				
Why must database migration scripts always be authored to exhibit idempotency?	So foreign keys are automatically deleted and regenerated as primary keys.	So the migration script executes in under one millisecond regardless of data volume.	So the script can execute without requiring database administrator credentials.	So executing the script multiple times produces the exact same schema state without failing or creating duplicate objects.	D	Idempotent migrations use guards like `IF NOT EXISTS`, ensuring safe retries if a network interruption halts partial deployment.	Databases	Database Design and Performance	Database migrations	Intermediate	Elements	computing, databases, database-design-and-performance, database-migrations				
Which deployment strategy enables zero-downtime database schema alterations without locking production tables against active applications?	Stopping all application server instances for offline maintenance windows.	Expand and Contract pattern (parallel-run schema evolution).	Dropping all foreign key constraints permanently from the catalog.	Direct hot-patching of physical disk block headers while queries run.	B	Expand-and-contract adds new columns/tables (expand), writes to both, migrates data, transitions reads, and deletes old columns (contract).	Databases	Database Design and Performance	Database migrations	Intermediate	Elements	computing, databases, database-design-and-performance, database-migrations				
Why must database migration scripts always be authored to exhibit idempotency?	So foreign keys are automatically deleted and regenerated as primary keys.	So executing the script multiple times produces the exact same schema state without failing or creating duplicate objects.	So the script can execute without requiring database administrator credentials.	So the migration script executes in under one millisecond regardless of data volume.	B	Idempotent migrations use guards like `IF NOT EXISTS`, ensuring safe retries if a network interruption halts partial deployment.	Databases	Database Design and Performance	Database migrations	Intermediate	Elements	computing, databases, database-design-and-performance, database-migrations				
In conceptual database design, what does total participation (mandatory presence) of an entity set in a relationship signify?	Every attribute in the entity set must be indexed as a unique candidate key.	The entity set must be mapped into physical solid-state disk storage.	Every entity in the entity set must participate in at least one relationship instance.	Entities in the set cannot participate in more than one relationship instance.	C	Total participation (indicated by a double line in Chen notation) requires that every entity instance is bound to the relationship.	Databases	Database Design and Performance	Entity-relationship modeling	Intermediate	Elements	computing, databases, database-design-and-performance, entity-relationship-modeling				
In Enhanced Entity-Relationship (EER) modeling, how does attribute inheritance operate across a specialization hierarchy?	The superclass inherits the primary key of its most recently created subclass.	Subclasses inherit only non-prime attributes and must redeclare foreign keys.	Subclasses automatically inherit all attributes and relationship participations of their generalized superclass.	Specialization hierarchies prohibit subclasses from declaring unique attributes.	C	Specialization defines IS-A relationships where specific entity subclasses inherit all properties of the parent superclass entity.	Databases	Database Design and Performance	Entity-relationship modeling	Intermediate	Elements	computing, databases, database-design-and-performance, entity-relationship-modeling				
In conceptual database design, what does total participation (mandatory presence) of an entity set in a relationship signify?	Every attribute in the entity set must be indexed as a unique candidate key.	The entity set must be mapped into physical solid-state disk storage.	Every entity in the entity set must participate in at least one relationship instance.	Entities in the set cannot participate in more than one relationship instance.	C	Total participation (indicated by a double line in Chen notation) requires that every entity instance is bound to the relationship.	Databases	Database Design and Performance	Entity-relationship modeling	Intermediate	Elements	computing, databases, database-design-and-performance, entity-relationship-modeling				
In Enhanced Entity-Relationship (EER) modeling, how does attribute inheritance operate across a specialization hierarchy?	The superclass inherits the primary key of its most recently created subclass.	Subclasses inherit only non-prime attributes and must redeclare foreign keys.	Subclasses automatically inherit all attributes and relationship participations of their generalized superclass.	Specialization hierarchies prohibit subclasses from declaring unique attributes.	C	Specialization defines IS-A relationships where specific entity subclasses inherit all properties of the parent superclass entity.	Databases	Database Design and Performance	Entity-relationship modeling	Intermediate	Elements	computing, databases, database-design-and-performance, entity-relationship-modeling				
A B-tree internal node resides in a block of $B = 4096$ bytes. Each record pointer requires $P = 8$ bytes and each search key requires $K = 24$ bytes. Calculate the maximum node fan-out $p$ such that $p \cdot P + (p - 1) \cdot K \le B$.	128	170	127	64	A	**Given:** Block size $B = 4096$, pointer size $P = 8$, key size $K = 24$. **Formula:** $p \cdot P + (p - 1) \cdot K \le B \implies p(P + K) - K \le B \implies p \le \frac{B + K}{P + K}$. **Calculation:** $p(8 + 24) - 24 \le 4096 \implies 32p - 24 \le 4096 \implies 32p \le 4120 \implies p \le \frac{4120}{32} = 128.75$. Maximum integer fan-out is 128. **Answer:** 128	Databases	Database Design and Performance	Index structures (B-tree)	Hard	Solving	computing, databases, database-design-and-performance, index-structures-b-tree				
What structural feature makes a B+ tree superior to a standard B-tree for processing SQL range queries (`BETWEEN a AND b`)?	Leaf nodes are linked in a continuous doubly-linked list, allowing fast sequential traversals without re-ascending the tree.	B+ trees convert range queries into hash lookups in constant time.	B+ trees eliminate the requirement for disk block pointers in internal nodes.	B+ trees store all table data compressed directly inside the root node.	A	Once the starting key is located in a leaf, range queries simply traverse adjacent leaf sibling pointers sequentially.	Databases	Database Design and Performance	Index structures (B-tree)	Intermediate	Elements	computing, databases, database-design-and-performance, index-structures-b-tree				
A B+ tree index has uniform node fan-out $f = 100$. If the root is at level 1, calculate the maximum number of leaf nodes located at level 3.	100 leaf nodes	1000 leaf nodes	10000 leaf nodes	1000000 leaf nodes	C	**Given:** Level 1 has 1 root node, fan-out $f = 100$. Level 3 is the leaf level. **Formula:** Maximum nodes at level $L$ = $f^{L - 1}$. **Calculation:** Level 1 (root): 1 node. Level 2 (intermediate): $1 \times 100 = 100$ nodes. Level 3 (leaves): $100 \times 100 = 10,000$ leaf nodes. **Answer:** 10000 leaf nodes	Databases	Database Design and Performance	Index structures (B-tree)	Hard	Solving	computing, databases, database-design-and-performance, index-structures-b-tree				
During an insertion into an already full B-tree node with order $m$, what structural operation occurs to maintain balance?	The oldest key in the full node is evicted to an overflow log file.	The entire B-tree is discarded and rebuilt from scratch in memory.	The node splits into two halves, and the median key is promoted to the parent node.	The root node is converted into an unindexed linked list.	C	Node splitting distributes keys evenly and pushes the middle key up, growing the tree upward at the root if needed.	Databases	Database Design and Performance	Index structures (B-tree)	Intermediate	Elements	computing, databases, database-design-and-performance, index-structures-b-tree				
What structural feature makes a B+ tree superior to a standard B-tree for processing SQL range queries (`BETWEEN a AND b`)?	Leaf nodes are linked in a continuous doubly-linked list, allowing fast sequential traversals without re-ascending the tree.	B+ trees convert range queries into hash lookups in constant time.	B+ trees eliminate the requirement for disk block pointers in internal nodes.	B+ trees store all table data compressed directly inside the root node.	A	Once the starting key is located in a leaf, range queries simply traverse adjacent leaf sibling pointers sequentially.	Databases	Database Design and Performance	Index structures (B-tree)	Intermediate	Elements	computing, databases, database-design-and-performance, index-structures-b-tree				
During an insertion into an already full B-tree node with order $m$, what structural operation occurs to maintain balance?	The oldest key in the full node is evicted to an overflow log file.	The entire B-tree is discarded and rebuilt from scratch in memory.	The node splits into two halves, and the median key is promoted to the parent node.	The root node is converted into an unindexed linked list.	C	Node splitting distributes keys evenly and pushes the middle key up, growing the tree upward at the root if needed.	Databases	Database Design and Performance	Index structures (B-tree)	Intermediate	Elements	computing, databases, database-design-and-performance, index-structures-b-tree				
A B-tree internal node resides in a block of $B = 4096$ bytes. Each record pointer requires $P = 8$ bytes and each search key requires $K = 24$ bytes. Calculate the maximum node fan-out $p$ such that $p \cdot P + (p - 1) \cdot K \le B$.	128	170	127	64	A	**Given:** Block size $B = 4096$, pointer size $P = 8$, key size $K = 24$. **Formula:** $p \cdot P + (p - 1) \cdot K \le B \implies p(P + K) - K \le B \implies p \le \frac{B + K}{P + K}$. **Calculation:** $p(8 + 24) - 24 \le 4096 \implies 32p - 24 \le 4096 \implies 32p \le 4120 \implies p \le \frac{4120}{32} = 128.75$. Maximum integer fan-out is 128. **Answer:** 128	Databases	Database Design and Performance	Index structures (B-tree)	Hard	Solving	computing, databases, database-design-and-performance, index-structures-b-tree				
A B+ tree index has uniform node fan-out $f = 100$. If the root is at level 1, calculate the maximum number of leaf nodes located at level 3.	100 leaf nodes	10000 leaf nodes	1000 leaf nodes	1000000 leaf nodes	B	**Given:** Level 1 has 1 root node, fan-out $f = 100$. Level 3 is the leaf level. **Formula:** Maximum nodes at level $L$ = $f^{L - 1}$. **Calculation:** Level 1 (root): 1 node. Level 2 (intermediate): $1 \times 100 = 100$ nodes. Level 3 (leaves): $100 \times 100 = 10,000$ leaf nodes. **Answer:** 10000 leaf nodes	Databases	Database Design and Performance	Index structures (B-tree)	Hard	Solving	computing, databases, database-design-and-performance, index-structures-b-tree				
A B-tree internal node resides in a block of $B = 4096$ bytes. Each record pointer requires $P = 8$ bytes and each search key requires $K = 24$ bytes. Calculate the maximum node fan-out $p$ such that $p \cdot P + (p - 1) \cdot K \le B$.	128	170	127	64	A	**Given:** Block size $B = 4096$, pointer size $P = 8$, key size $K = 24$. **Formula:** $p \cdot P + (p - 1) \cdot K \le B \implies p(P + K) - K \le B \implies p \le \frac{B + K}{P + K}$. **Calculation:** $p(8 + 24) - 24 \le 4096 \implies 32p - 24 \le 4096 \implies 32p \le 4120 \implies p \le \frac{4120}{32} = 128.75$. Maximum integer fan-out is 128. **Answer:** 128	Databases	Database Design and Performance	Index structures (B-tree)	Intermediate	Solving	computing, databases, database-design-and-performance, index-structures-b-tree				
A B+ tree index has uniform node fan-out $f = 100$. If the root is at level 1, calculate the maximum number of leaf nodes located at level 3.	100 leaf nodes	10000 leaf nodes	1000 leaf nodes	1000000 leaf nodes	B	**Given:** Level 1 has 1 root node, fan-out $f = 100$. Level 3 is the leaf level. **Formula:** Maximum nodes at level $L$ = $f^{L - 1}$. **Calculation:** Level 1 (root): 1 node. Level 2 (intermediate): $1 \times 100 = 100$ nodes. Level 3 (leaves): $100 \times 100 = 10,000$ leaf nodes. **Answer:** 10000 leaf nodes	Databases	Database Design and Performance	Index structures (B-tree)	Intermediate	Solving	computing, databases, database-design-and-performance, index-structures-b-tree				
Which concurrency phenomenon occurs when Transaction T1 reads data modified by concurrent Transaction T2, but T2 subsequently rolls back?	Non-repeatable read.	Phantom read.	Dirty read.	Lost update.	C	A dirty read reads uncommitted state that never officially existed if the writing transaction aborts.	Databases	Database Design and Performance	Isolation levels	Intermediate	Elements	computing, databases, database-design-and-performance, isolation-levels				
What is the strictest ANSI SQL isolation level that guarantees concurrent transactions execute with outcomes identical to a purely sequential execution?	Repeatable Read.	Read Uncommitted.	Read Committed.	Serializable.	D	Serializable completely eliminates dirty reads, non-repeatable reads, and phantom reads, enforcing conflict or view serializability.	Databases	Database Design and Performance	Isolation levels	Intermediate	Elements	computing, databases, database-design-and-performance, isolation-levels				
Which concurrency phenomenon occurs when Transaction T1 reads data modified by concurrent Transaction T2, but T2 subsequently rolls back?	Dirty read.	Phantom read.	Non-repeatable read.	Lost update.	A	A dirty read reads uncommitted state that never officially existed if the writing transaction aborts.	Databases	Database Design and Performance	Isolation levels	Intermediate	Elements	computing, databases, database-design-and-performance, isolation-levels				
What is the strictest ANSI SQL isolation level that guarantees concurrent transactions execute with outcomes identical to a purely sequential execution?	Serializable.	Read Uncommitted.	Read Committed.	Repeatable Read.	A	Serializable completely eliminates dirty reads, non-repeatable reads, and phantom reads, enforcing conflict or view serializability.	Databases	Database Design and Performance	Isolation levels	Intermediate	Elements	computing, databases, database-design-and-performance, isolation-levels				
How does a modern Cost-Based Optimizer (CBO) select an execution plan for a complex SQL query?	It executes all candidate plans concurrently and chooses the first plan that returns a row.	It strictly relies on hardcoded syntactic rules prioritizing indexes regardless of table size.	It delegates execution plan choice to the client-side application driver.	It estimates the disk I/O, CPU cycles, and network costs of candidate plans using catalog table statistics and histograms.	D	A cost-based optimizer evaluates candidate trees using data distribution statistics, selecting the minimum estimated cost plan.	Databases	Database Design and Performance	Query optimization	Intermediate	Elements	computing, databases, database-design-and-performance, query-optimization				
Why might a cost-based query optimizer choose a full sequential table scan instead of using an existing B-tree index?	Because SQL standards prohibit index usage on tables that possess primary keys.	Because B-tree indexes cannot be evaluated when tables contain more than 100 rows.	Because sequential scans automatically bypass database transaction log locks.	When the query predicate matches a large percentage of table rows, sequential I/O is faster than random index lookups.	D	When selectivity is low (e.g. retrieving 30%+ of rows), sequential page reads have lower overhead than repeated random index page seeks.	Databases	Database Design and Performance	Query optimization	Intermediate	Elements	computing, databases, database-design-and-performance, query-optimization				
How does a modern Cost-Based Optimizer (CBO) select an execution plan for a complex SQL query?	It executes all candidate plans concurrently and chooses the first plan that returns a row.	It estimates the disk I/O, CPU cycles, and network costs of candidate plans using catalog table statistics and histograms.	It delegates execution plan choice to the client-side application driver.	It strictly relies on hardcoded syntactic rules prioritizing indexes regardless of table size.	B	A cost-based optimizer evaluates candidate trees using data distribution statistics, selecting the minimum estimated cost plan.	Databases	Database Design and Performance	Query optimization	Intermediate	Elements	computing, databases, database-design-and-performance, query-optimization				
Why might a cost-based query optimizer choose a full sequential table scan instead of using an existing B-tree index?	Because SQL standards prohibit index usage on tables that possess primary keys.	When the query predicate matches a large percentage of table rows, sequential I/O is faster than random index lookups.	Because sequential scans automatically bypass database transaction log locks.	Because B-tree indexes cannot be evaluated when tables contain more than 100 rows.	B	When selectivity is low (e.g. retrieving 30%+ of rows), sequential page reads have lower overhead than repeated random index page seeks.	Databases	Database Design and Performance	Query optimization	Intermediate	Elements	computing, databases, database-design-and-performance, query-optimization				
In Entity-Relationship (ER) modeling, what distinguishes a weak entity set from a regular strong entity set?	A weak entity set cannot participate in relationship sets with cardinality greater than one.	A weak entity set is never mapped into physical relational database tables.	A weak entity set lacks a primary key of its own and depends on an owner entity set for identification.	A weak entity set contains only numeric integer columns and no strings.	C	A weak entity relies on an identifying owner entity; its primary key is formed by owner key plus its partial discriminator.	Databases	Relational Databases	ER diagrams	Intermediate	Elements	computing, databases, relational-databases, er-diagrams				
In an ER diagram modeling employees and projects where each employee can work on multiple projects and each project has multiple employees, what cardinality applies?	One-to-One (1:1).	Many-to-Many (M:N).	Many-to-One (N:1).	One-to-Many (1:N).	B	When entities on both sides can relate to multiple instances on the opposite side, the cardinality ratio is many-to-many (M:N).	Databases	Relational Databases	ER diagrams	Intermediate	Elements	computing, databases, relational-databases, er-diagrams				
In Entity-Relationship (ER) modeling, what distinguishes a weak entity set from a regular strong entity set?	A weak entity set cannot participate in relationship sets with cardinality greater than one.	A weak entity set is never mapped into physical relational database tables.	A weak entity set lacks a primary key of its own and depends on an owner entity set for identification.	A weak entity set contains only numeric integer columns and no strings.	C	A weak entity relies on an identifying owner entity; its primary key is formed by owner key plus its partial discriminator.	Databases	Relational Databases	ER diagrams	Intermediate	Elements	computing, databases, relational-databases, er-diagrams				
In an ER diagram modeling employees and projects where each employee can work on multiple projects and each project has multiple employees, what cardinality applies?	One-to-One (1:1).	Many-to-Many (M:N).	Many-to-One (N:1).	One-to-Many (1:N).	B	When entities on both sides can relate to multiple instances on the opposite side, the cardinality ratio is many-to-many (M:N).	Databases	Relational Databases	ER diagrams	Intermediate	Elements	computing, databases, relational-databases, er-diagrams				
For relation $R(A, B, C, D, E)$ with functional dependencies $F = \{ A \to B, B \to C, CD \to E \}$, calculate the attribute closure $A^+$.	{A, B}	{A, B, C, D}	{A, B, C, D, E}	{A, B, C}	D	**Given:** Relation $R(A, B, C, D, E)$, FDs: $A \to B$, $B \to C$, $CD \to E$. **Formula:** Start with $X^+ = \{A\}$; iteratively add RHS of any FD whose LHS is contained in $X^+$. **Calculation:** Step 1: $A^+ = \{A\}$. Step 2: $A \to B \implies A^+ = \{A, B\}$. Step 3: $B \to C \implies A^+ = \{A, B, C\}$. Step 4: $CD \to E$ cannot fire because $D \notin A^+$. Thus $A^+ = \{A, B, C\}$. **Answer:** {A, B, C}	Databases	Relational Databases	Functional dependencies	Alien	Solving	computing, databases, relational-databases, functional-dependencies				
Under what condition is a functional dependency $X \to Y$ formally classified as trivial?	When the relation contains zero records at design time.	When the attribute set Y is a subset of attribute set X (Y \subseteq X).	When the attribute set Y consists entirely of numeric data types.	When the attribute set X contains only a single attribute column.	B	A dependency $X \to Y$ is trivial if it holds by definition of set inclusion ($Y \subseteq X$), such as $AB \to A$.	Databases	Relational Databases	Functional dependencies	Intermediate	Elements	computing, databases, relational-databases, functional-dependencies				
Relation $R(A, B, C, D)$ has functional dependencies $F = \{ AB \to C, C \to D, D \to A \}$. Determine a minimal candidate key for relation $R$.	AB	D	CD	A	A	**Given:** Relation $R(A, B, C, D)$, FDs: $AB \to C$, $C \to D$, $D \to A$. **Formula:** A candidate key $K$ must satisfy $K^+ = \{A, B, C, D\}$ with no proper subset determining all attributes. **Calculation:** Attribute $B$ does not appear on the RHS of any FD, so $B$ must be in every candidate key. Testing $(AB)^+$: $(AB)^+ = \{A, B\} \to \{A, B, C\} \to \{A, B, C, D\}$. Proper subsets $A^+=\{A\}$ and $B^+=\{B\}$ do not determine all. Thus $AB$ is a minimal candidate key. **Answer:** AB	Databases	Relational Databases	Functional dependencies	Hard	Solving	computing, databases, relational-databases, functional-dependencies				
What is an extraneous attribute in a set of functional dependencies $F$?	An attribute that accepts NULL values during bulk insert operations.	An attribute that belongs exclusively to an archived audit log table.	An attribute that can be removed from an FD without changing the overall closure F+.	An attribute that is not indexed in the physical storage engine.	C	In minimal cover computation, attributes whose removal preserves closure equivalence $F^+ \equiv (F - \{A\})^+ $ are extraneous.	Databases	Relational Databases	Functional dependencies	Intermediate	Elements	computing, databases, relational-databases, functional-dependencies				
Under what condition is a functional dependency $X \to Y$ formally classified as trivial?	When the relation contains zero records at design time.	When the attribute set Y is a subset of attribute set X (Y \subseteq X).	When the attribute set Y consists entirely of numeric data types.	When the attribute set X contains only a single attribute column.	B	A dependency $X \to Y$ is trivial if it holds by definition of set inclusion ($Y \subseteq X$), such as $AB \to A$.	Databases	Relational Databases	Functional dependencies	Intermediate	Elements	computing, databases, relational-databases, functional-dependencies				
What is an extraneous attribute in a set of functional dependencies $F$?	An attribute that accepts NULL values during bulk insert operations.	An attribute that belongs exclusively to an archived audit log table.	An attribute that can be removed from an FD without changing the overall closure F+.	An attribute that is not indexed in the physical storage engine.	C	In minimal cover computation, attributes whose removal preserves closure equivalence $F^+ \equiv (F - \{A\})^+ $ are extraneous.	Databases	Relational Databases	Functional dependencies	Intermediate	Elements	computing, databases, relational-databases, functional-dependencies				
For relation $R(A, B, C, D, E)$ with functional dependencies $F = \{ A \to B, B \to C, CD \to E \}$, calculate the attribute closure $A^+$.	{A, B}	{A, B, C, D}	{A, B, C, D, E}	{A, B, C}	D	**Given:** Relation $R(A, B, C, D, E)$, FDs: $A \to B$, $B \to C$, $CD \to E$. **Formula:** Start with $X^+ = \{A\}$; iteratively add RHS of any FD whose LHS is contained in $X^+$. **Calculation:** Step 1: $A^+ = \{A\}$. Step 2: $A \to B \implies A^+ = \{A, B\}$. Step 3: $B \to C \implies A^+ = \{A, B, C\}$. Step 4: $CD \to E$ cannot fire because $D \notin A^+$. Thus $A^+ = \{A, B, C\}$. **Answer:** {A, B, C}	Databases	Relational Databases	Functional dependencies	Hard	Solving	computing, databases, relational-databases, functional-dependencies				
Relation $R(A, B, C, D)$ has functional dependencies $F = \{ AB \to C, C \to D, D \to A \}$. Determine a minimal candidate key for relation $R$.	AB	D	CD	A	A	**Given:** Relation $R(A, B, C, D)$, FDs: $AB \to C$, $C \to D$, $D \to A$. **Formula:** A candidate key $K$ must satisfy $K^+ = \{A, B, C, D\}$ with no proper subset determining all attributes. **Calculation:** Attribute $B$ does not appear on the RHS of any FD, so $B$ must be in every candidate key. Testing $(AB)^+$: $(AB)^+ = \{A, B\} \to \{A, B, C\} \to \{A, B, C, D\}$. Proper subsets $A^+=\{A\}$ and $B^+=\{B\}$ do not determine all. Thus $AB$ is a minimal candidate key. **Answer:** AB	Databases	Relational Databases	Functional dependencies	Hard	Solving	computing, databases, relational-databases, functional-dependencies				
For relation $R(A, B, C, D, E)$ with functional dependencies $F = \{ A \to B, B \to C, CD \to E \}$, calculate the attribute closure $A^+$.	{A, B}	{A, B, C, D}	{A, B, C, D, E}	{A, B, C}	D	**Given:** Relation $R(A, B, C, D, E)$, FDs: $A \to B$, $B \to C$, $CD \to E$. **Formula:** Start with $X^+ = \{A\}$; iteratively add RHS of any FD whose LHS is contained in $X^+$. **Calculation:** Step 1: $A^+ = \{A\}$. Step 2: $A \to B \implies A^+ = \{A, B\}$. Step 3: $B \to C \implies A^+ = \{A, B, C\}$. Step 4: $CD \to E$ cannot fire because $D \notin A^+$. Thus $A^+ = \{A, B, C\}$. **Answer:** {A, B, C}	Databases	Relational Databases	Functional dependencies	Intermediate	Solving	computing, databases, relational-databases, functional-dependencies				
Relation $R(A, B, C, D)$ has functional dependencies $F = \{ AB \to C, C \to D, D \to A \}$. Determine a minimal candidate key for relation $R$.	AB	D	CD	A	A	**Given:** Relation $R(A, B, C, D)$, FDs: $AB \to C$, $C \to D$, $D \to A$. **Formula:** A candidate key $K$ must satisfy $K^+ = \{A, B, C, D\}$ with no proper subset determining all attributes. **Calculation:** Attribute $B$ does not appear on the RHS of any FD, so $B$ must be in every candidate key. Testing $(AB)^+$: $(AB)^+ = \{A, B\} \to \{A, B, C\} \to \{A, B, C, D\}$. Proper subsets $A^+=\{A\}$ and $B^+=\{B\}$ do not determine all. Thus $AB$ is a minimal candidate key. **Answer:** AB	Databases	Relational Databases	Functional dependencies	Intermediate	Solving	computing, databases, relational-databases, functional-dependencies				
Which relational rule is defined by the Entity Integrity constraint?	Every foreign key attribute must reference an existing foreign key in another table.	No attribute participating in the primary key of a base relation may accept a NULL value.	Numeric attribute values must conform strictly to positive integers.	All non-prime attributes in a table must store unique values across all rows.	B	Entity integrity guarantees each individual tuple can be distinguished uniquely, prohibiting NULL in primary key attributes.	Databases	Relational Databases	Integrity constraints	Basic	Elements	computing, databases, relational-databases, integrity-constraints				
Under referential integrity, what are the two permissible states for a foreign key value in a child table?	It must be strictly unique within the child table and strictly non-zero.	It must be smaller than the minimum primary key in the child table.	It must match an indexed view definition and be non-numeric.	It must either match an existing primary key value in the referenced parent table or be entirely NULL.	D	Referential integrity ensures that references to other entities remain valid; if present, the foreign key must reference an actual tuple or be NULL.	Databases	Relational Databases	Integrity constraints	Intermediate	Elements	computing, databases, relational-databases, integrity-constraints				
Which relational rule is defined by the Entity Integrity constraint?	Every foreign key attribute must reference an existing foreign key in another table.	No attribute participating in the primary key of a base relation may accept a NULL value.	Numeric attribute values must conform strictly to positive integers.	All non-prime attributes in a table must store unique values across all rows.	B	Entity integrity guarantees each individual tuple can be distinguished uniquely, prohibiting NULL in primary key attributes.	Databases	Relational Databases	Integrity constraints	Basic	Elements	computing, databases, relational-databases, integrity-constraints				
Under referential integrity, what are the two permissible states for a foreign key value in a child table?	It must be strictly unique within the child table and strictly non-zero.	It must be smaller than the minimum primary key in the child table.	It must match an indexed view definition and be non-numeric.	It must either match an existing primary key value in the referenced parent table or be entirely NULL.	D	Referential integrity ensures that references to other entities remain valid; if present, the foreign key must reference an actual tuple or be NULL.	Databases	Relational Databases	Integrity constraints	Intermediate	Elements	computing, databases, relational-databases, integrity-constraints				
Relation $R(A, B, C)$ has functional dependencies $F = \{ AB \to C, C \to B \}$. Candidate keys are $AB$ and $AC$. Why does relation $R$ violate Boyce-Codd Normal Form (BCNF)?	In dependency AB -> C, determinant AB is not a superkey.	Relation R violates 1NF due to non-atomic attribute values.	Attribute B is a prime attribute belonging to candidate key AB.	In dependency C -> B, determinant C is not a superkey.	D	**Given:** Relation $R(A, B, C)$, Candidate keys $AB, AC$, FDs: $AB \to C$, $C \to B$. **Formula:** A relation is in BCNF if for every non-trivial functional dependency $X \to Y$, determinant $X$ is a superkey. **Calculation:** For $AB \to C$, $AB$ is a superkey. For $C \to B$, $C^+ = \{B, C\} \neq \{A, B, C\}$, so $C$ is not a superkey. Therefore, $C \to B$ violates BCNF (even though $R$ is in 3NF because $B$ is prime). **Answer:** In dependency C -> B, determinant C is not a superkey.	Databases	Relational Databases	Normal forms (1NF to BCNF)	Hard	Solving	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
How does the definition of Third Normal Form (3NF) relax the strict requirement of Boyce-Codd Normal Form (BCNF)?	3NF eliminates the requirement for relations to satisfy First Normal Form.	3NF allows X -> Y if determinant X is a superkey OR dependent attribute Y is a prime attribute.	3NF allows relations to store non-atomic repeating groups and nested tables.	3NF permits partial dependencies on composite candidate keys.	B	For $X \to Y$, 3NF requires $X$ to be a superkey OR $Y$ to be part of some candidate key (prime attribute). BCNF requires $X$ to be a superkey.	Databases	Relational Databases	Normal forms (1NF to BCNF)	Basic	Elements	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
Decompose relation $R(A, B, C)$ with $F = \{ AB \to C, C \to B \}$ into BCNF using BCNF decomposition. What is the resulting lossless schema decomposition?	R1(C, B) and R2(A, C)	R1(A, B) and R2(A, C)	R1(A, B, C) with no decomposition needed	R1(A, B) and R2(B, C)	A	**Given:** $R(A, B, C)$, violating FD is $C \to B$. **Formula:** Decompose into $R_1(X \cup Y) = R_1(C, B)$ and $R_2(R - Y) = R_2(A, C)$. **Calculation:** Violating FD is $C \to B$. Create $R_1(C, B)$ with key $C$. Remaining attributes form $R_2(A, C)$ with key $AC$. Common attribute $R_1 \cap R_2 = \{C\}$, which is a key for $R_1$, guaranteeing a lossless join. **Answer:** R1(C, B) and R2(A, C)	Databases	Relational Databases	Normal forms (1NF to BCNF)	Tricky	Solving	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
Which condition defines Second Normal Form (2NF) for a relation already satisfying 1NF?	No non-prime attribute is functionally dependent on a proper subset of any candidate key.	Every determinant in the relation must be a superkey of the table.	All foreign keys must reference primary keys located on identical physical storage.	No two rows in the relation may share identical values in any attribute.	A	2NF eliminates partial dependencies: every non-prime attribute must depend on the whole of every candidate key.	Databases	Relational Databases	Normal forms (1NF to BCNF)	Basic	Elements	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
How does the definition of Third Normal Form (3NF) relax the strict requirement of Boyce-Codd Normal Form (BCNF)?	3NF eliminates the requirement for relations to satisfy First Normal Form.	3NF allows X -> Y if determinant X is a superkey OR dependent attribute Y is a prime attribute.	3NF allows relations to store non-atomic repeating groups and nested tables.	3NF permits partial dependencies on composite candidate keys.	B	For $X \to Y$, 3NF requires $X$ to be a superkey OR $Y$ to be part of some candidate key (prime attribute). BCNF requires $X$ to be a superkey.	Databases	Relational Databases	Normal forms (1NF to BCNF)	Basic	Elements	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
Which condition defines Second Normal Form (2NF) for a relation already satisfying 1NF?	No non-prime attribute is functionally dependent on a proper subset of any candidate key.	Every determinant in the relation must be a superkey of the table.	All foreign keys must reference primary keys located on identical physical storage.	No two rows in the relation may share identical values in any attribute.	A	2NF eliminates partial dependencies: every non-prime attribute must depend on the whole of every candidate key.	Databases	Relational Databases	Normal forms (1NF to BCNF)	Basic	Elements	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
Relation $R(A, B, C)$ has functional dependencies $F = \{ AB \to C, C \to B \}$. Candidate keys are $AB$ and $AC$. Why does relation $R$ violate Boyce-Codd Normal Form (BCNF)?	In dependency AB -> C, determinant AB is not a superkey.	Relation R violates 1NF due to non-atomic attribute values.	Attribute B is a prime attribute belonging to candidate key AB.	In dependency C -> B, determinant C is not a superkey.	D	**Given:** Relation $R(A, B, C)$, Candidate keys $AB, AC$, FDs: $AB \to C$, $C \to B$. **Formula:** A relation is in BCNF if for every non-trivial functional dependency $X \to Y$, determinant $X$ is a superkey. **Calculation:** For $AB \to C$, $AB$ is a superkey. For $C \to B$, $C^+ = \{B, C\} \neq \{A, B, C\}$, so $C$ is not a superkey. Therefore, $C \to B$ violates BCNF (even though $R$ is in 3NF because $B$ is prime). **Answer:** In dependency C -> B, determinant C is not a superkey.	Databases	Relational Databases	Normal forms (1NF to BCNF)	Hard	Solving	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
Decompose relation $R(A, B, C)$ with $F = \{ AB \to C, C \to B \}$ into BCNF using BCNF decomposition. What is the resulting lossless schema decomposition?	R1(C, B) and R2(A, C)	R1(A, B) and R2(A, C)	R1(A, B, C) with no decomposition needed	R1(A, B) and R2(B, C)	A	**Given:** $R(A, B, C)$, violating FD is $C \to B$. **Formula:** Decompose into $R_1(X \cup Y) = R_1(C, B)$ and $R_2(R - Y) = R_2(A, C)$. **Calculation:** Violating FD is $C \to B$. Create $R_1(C, B)$ with key $C$. Remaining attributes form $R_2(A, C)$ with key $AC$. Common attribute $R_1 \cap R_2 = \{C\}$, which is a key for $R_1$, guaranteeing a lossless join. **Answer:** R1(C, B) and R2(A, C)	Databases	Relational Databases	Normal forms (1NF to BCNF)	Hard	Solving	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
Relation $R(A, B, C)$ has functional dependencies $F = \{ AB \to C, C \to B \}$. Candidate keys are $AB$ and $AC$. Why does relation $R$ violate Boyce-Codd Normal Form (BCNF)?	In dependency AB -> C, determinant AB is not a superkey.	Relation R violates 1NF due to non-atomic attribute values.	Attribute B is a prime attribute belonging to candidate key AB.	In dependency C -> B, determinant C is not a superkey.	D	**Given:** Relation $R(A, B, C)$, Candidate keys $AB, AC$, FDs: $AB \to C$, $C \to B$. **Formula:** A relation is in BCNF if for every non-trivial functional dependency $X \to Y$, determinant $X$ is a superkey. **Calculation:** For $AB \to C$, $AB$ is a superkey. For $C \to B$, $C^+ = \{B, C\} \neq \{A, B, C\}$, so $C$ is not a superkey. Therefore, $C \to B$ violates BCNF (even though $R$ is in 3NF because $B$ is prime). **Answer:** In dependency C -> B, determinant C is not a superkey.	Databases	Relational Databases	Normal forms (1NF to BCNF)	Intermediate	Solving	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
Decompose relation $R(A, B, C)$ with $F = \{ AB \to C, C \to B \}$ into BCNF using BCNF decomposition. What is the resulting lossless schema decomposition?	R1(C, B) and R2(A, C)	R1(A, B) and R2(A, C)	R1(A, B, C) with no decomposition needed	R1(A, B) and R2(B, C)	A	**Given:** $R(A, B, C)$, violating FD is $C \to B$. **Formula:** Decompose into $R_1(X \cup Y) = R_1(C, B)$ and $R_2(R - Y) = R_2(A, C)$. **Calculation:** Violating FD is $C \to B$. Create $R_1(C, B)$ with key $C$. Remaining attributes form $R_2(A, C)$ with key $AC$. Common attribute $R_1 \cap R_2 = \{C\}$, which is a key for $R_1$, guaranteeing a lossless join. **Answer:** R1(C, B) and R2(A, C)	Databases	Relational Databases	Normal forms (1NF to BCNF)	Intermediate	Solving	computing, databases, relational-databases, normal-forms-1nf-to-bcnf				
A relation $R(A, B, C, D)$ has candidate key $AB$ and functional dependencies $F = \{ AB \to CD, B \to C \}$. Determine the highest normal form satisfied by relation $R$.	Second Normal Form (2NF)	First Normal Form (1NF)	Third Normal Form (3NF)	Boyce-Codd Normal Form (BCNF)	B	**Given:** Relation $R(A, B, C, D)$, Candidate key $AB$, FDs: $AB \to CD$, $B \to C$. **Formula:** A relation is in 2NF if it is in 1NF and no non-prime attribute is partially dependent on any candidate key. **Calculation:** Prime attributes are $A, B$; non-prime are $C, D$. Dependency $B \to C$ shows non-prime attribute $C$ depends on proper subset $B$ of candidate key $AB$ (partial dependency). Thus $R$ violates 2NF and is only in 1NF. **Answer:** First Normal Form (1NF)	Databases	Relational Databases	Normalization	Hard	Solving	computing, databases, relational-databases, normalization				
In an unnormalized database, which anomaly occurs when deleting an employee unintentionally deletes the only record of an entire department?	Concurrency deadlock anomaly.	Update anomaly.	Insertion anomaly.	Deletion anomaly.	D	A deletion anomaly results in the unintentional loss of secondary information when a tuple containing mixed facts is removed.	Databases	Relational Databases	Normalization	Intermediate	Elements	computing, databases, relational-databases, normalization				
Relation $R(A, B, C, D)$ has candidate key $A$ and functional dependencies $F = \{ A \to BCD, B \to C \}$. Identify the highest normal form of $R$.	Boyce-Codd Normal Form (BCNF)	Second Normal Form (2NF)	Third Normal Form (3NF)	First Normal Form (1NF)	B	**Given:** Relation $R(A, B, C, D)$, Candidate key $A$, FDs: $A \to BCD$, $B \to C$. **Formula:** A relation is in 3NF if in 2NF and no non-prime attribute is transitively dependent on any candidate key. **Calculation:** Key is $A$ (single attribute), so no partial dependencies exist; $R$ is in 2NF. However, $A \to B$ and $B \to C$ where $C$ is non-prime yields a transitive dependency $A \to C$. This violates 3NF, so highest form is 2NF. **Answer:** Second Normal Form (2NF)	Databases	Relational Databases	Normalization	Hard	Solving	computing, databases, relational-databases, normalization				
Which requirement must always be strictly satisfied during relational schema decomposition to ensure reconstructed queries produce identical data?	Equal distribution of columns across all partitioned tables.	Lossless join property (non-additive join property).	Strict minimization of the total number of foreign keys.	Complete elimination of all composite primary keys.	B	A decomposition must guarantee a lossless join so natural join of decomposed relations generates exactly original tuples without spurious rows.	Databases	Relational Databases	Normalization	Intermediate	Elements	computing, databases, relational-databases, normalization				
In an unnormalized database, which anomaly occurs when deleting an employee unintentionally deletes the only record of an entire department?	Concurrency deadlock anomaly.	Update anomaly.	Insertion anomaly.	Deletion anomaly.	D	A deletion anomaly results in the unintentional loss of secondary information when a tuple containing mixed facts is removed.	Databases	Relational Databases	Normalization	Intermediate	Elements	computing, databases, relational-databases, normalization				
Which requirement must always be strictly satisfied during relational schema decomposition to ensure reconstructed queries produce identical data?	Equal distribution of columns across all partitioned tables.	Lossless join property (non-additive join property).	Strict minimization of the total number of foreign keys.	Complete elimination of all composite primary keys.	B	A decomposition must guarantee a lossless join so natural join of decomposed relations generates exactly original tuples without spurious rows.	Databases	Relational Databases	Normalization	Intermediate	Elements	computing, databases, relational-databases, normalization				
A relation $R(A, B, C, D)$ has candidate key $AB$ and functional dependencies $F = \{ AB \to CD, B \to C \}$. Determine the highest normal form satisfied by relation $R$.	Second Normal Form (2NF)	First Normal Form (1NF)	Third Normal Form (3NF)	Boyce-Codd Normal Form (BCNF)	B	**Given:** Relation $R(A, B, C, D)$, Candidate key $AB$, FDs: $AB \to CD$, $B \to C$. **Formula:** A relation is in 2NF if it is in 1NF and no non-prime attribute is partially dependent on any candidate key. **Calculation:** Prime attributes are $A, B$; non-prime are $C, D$. Dependency $B \to C$ shows non-prime attribute $C$ depends on proper subset $B$ of candidate key $AB$ (partial dependency). Thus $R$ violates 2NF and is only in 1NF. **Answer:** First Normal Form (1NF)	Databases	Relational Databases	Normalization	Hard	Solving	computing, databases, relational-databases, normalization				
Relation $R(A, B, C, D)$ has candidate key $A$ and functional dependencies $F = \{ A \to BCD, B \to C \}$. Identify the highest normal form of $R$.	Boyce-Codd Normal Form (BCNF)	Second Normal Form (2NF)	Third Normal Form (3NF)	First Normal Form (1NF)	B	**Given:** Relation $R(A, B, C, D)$, Candidate key $A$, FDs: $A \to BCD$, $B \to C$. **Formula:** A relation is in 3NF if in 2NF and no non-prime attribute is transitively dependent on any candidate key. **Calculation:** Key is $A$ (single attribute), so no partial dependencies exist; $R$ is in 2NF. However, $A \to B$ and $B \to C$ where $C$ is non-prime yields a transitive dependency $A \to C$. This violates 3NF, so highest form is 2NF. **Answer:** Second Normal Form (2NF)	Databases	Relational Databases	Normalization	Hard	Solving	computing, databases, relational-databases, normalization				
A relation $R(A, B, C, D)$ has candidate key $AB$ and functional dependencies $F = \{ AB \to CD, B \to C \}$. Determine the highest normal form satisfied by relation $R$.	Second Normal Form (2NF)	Boyce-Codd Normal Form (BCNF)	Third Normal Form (3NF)	First Normal Form (1NF)	D	**Given:** Relation $R(A, B, C, D)$, Candidate key $AB$, FDs: $AB \to CD$, $B \to C$. **Formula:** A relation is in 2NF if it is in 1NF and no non-prime attribute is partially dependent on any candidate key. **Calculation:** Prime attributes are $A, B$; non-prime are $C, D$. Dependency $B \to C$ shows non-prime attribute $C$ depends on proper subset $B$ of candidate key $AB$ (partial dependency). Thus $R$ violates 2NF and is only in 1NF. **Answer:** First Normal Form (1NF)	Databases	Relational Databases	Normalization	Intermediate	Solving	computing, databases, relational-databases, normalization				
Relation $R(A, B, C, D)$ has candidate key $A$ and functional dependencies $F = \{ A \to BCD, B \to C \}$. Identify the highest normal form of $R$.	Boyce-Codd Normal Form (BCNF)	First Normal Form (1NF)	Third Normal Form (3NF)	Second Normal Form (2NF)	D	**Given:** Relation $R(A, B, C, D)$, Candidate key $A$, FDs: $A \to BCD$, $B \to C$. **Formula:** A relation is in 3NF if in 2NF and no non-prime attribute is transitively dependent on any candidate key. **Calculation:** Key is $A$ (single attribute), so no partial dependencies exist; $R$ is in 2NF. However, $A \to B$ and $B \to C$ where $C$ is non-prime yields a transitive dependency $A \to C$. This violates 3NF, so highest form is 2NF. **Answer:** Second Normal Form (2NF)	Databases	Relational Databases	Normalization	Intermediate	Solving	computing, databases, relational-databases, normalization				
Relation $R$ contains $|R| = 20$ tuples and relation $S$ contains $|S| = 15$ tuples. Calculate the exact cardinality of their Cartesian product $R \times S$.	35 tuples	150 tuples	300 tuples	3000 tuples	C	**Given:** $|R| = 20$, $|S| = 15$. **Formula:** $|R \times S| = |R| \times |S|$ **Calculation:** $|R \times S| = 20 \times 15 = 300\text{ tuples}$. **Answer:** 300 tuples	Databases	Relational Databases	Relational algebra	Intermediate	Solving	computing, databases, relational-databases, relational-algebra				
What is the fundamental difference between the relational algebra selection ($\sigma$) and projection ($\pi$) operators?	Selection operates on physical disk pages, while projection operates on cached memory.	Selection combines two tables, while projection partitions a single table into pairs.	Selection yields a horizontal subset of rows, while projection yields a vertical subset of columns.	Selection discards duplicate rows, while projection retains duplicate records.	C	Selection $\sigma$ filters rows based on a boolean condition; projection $\pi$ extracts specified attribute columns.	Databases	Relational Databases	Relational algebra	Intermediate	Elements	computing, databases, relational-databases, relational-algebra				
Relation $R(A, B)$ has $|R| = 10$ tuples and relation $S(B, C)$ has $|S| = 6$ tuples. If every tuple in $R$ matches every tuple in $S$ on attribute $B$, calculate the maximum possible cardinality of $R \bowtie S$.	60 tuples	16 tuples	6 tuples	10 tuples	A	**Given:** $|R| = 10$, $|S| = 6$, all tuples share an identical value on join attribute $B$. **Formula:** $\max |R \bowtie S| = |R| \times |S|$ when all join keys match. **Calculation:** $\max |R \bowtie S| = 10 \times 6 = 60\text{ tuples}$. **Answer:** 60 tuples	Databases	Relational Databases	Relational algebra	Hard	Solving	computing, databases, relational-databases, relational-algebra				
Which condition must be satisfied for two relations $R$ and $S$ to be valid operands for relational union ($R \cup S$) and set difference ($R - S$)?	Identical cardinality: both tables must contain the exact same number of tuples.	Union compatibility: both relations must have the same number of attributes with compatible data domains.	Referential coupling: one table must declare a foreign key referencing the other.	Key parity: both relations must share identical primary key column names.	B	Union compatibility (type compatibility) requires identical degree and pairwise compatible attribute domains.	Databases	Relational Databases	Relational algebra	Intermediate	Elements	computing, databases, relational-databases, relational-algebra				
Union-compatible relations $R$ and $S$ have $|R| = 40$ tuples and $|S| = 25$ tuples. If their intersection contains $|R \cap S| = 10$ tuples, calculate the cardinality of $R \cup S$.	65 tuples	50 tuples	55 tuples	75 tuples	C	**Given:** $|R| = 40$, $|S| = 25$, $|R \cap S| = 10$. **Formula:** $|R \cup S| = |R| + |S| - |R \cap S|$ **Calculation:** $|R \cup S| = 40 + 25 - 10 = 65 - 10 = 55\text{ tuples}$. **Answer:** 55 tuples	Databases	Relational Databases	Relational algebra	Intermediate	Solving	computing, databases, relational-databases, relational-algebra				
What is the fundamental difference between the relational algebra selection ($\sigma$) and projection ($\pi$) operators?	Selection operates on physical disk pages, while projection operates on cached memory.	Selection combines two tables, while projection partitions a single table into pairs.	Selection yields a horizontal subset of rows, while projection yields a vertical subset of columns.	Selection discards duplicate rows, while projection retains duplicate records.	C	Selection $\sigma$ filters rows based on a boolean condition; projection $\pi$ extracts specified attribute columns.	Databases	Relational Databases	Relational algebra	Intermediate	Elements	computing, databases, relational-databases, relational-algebra				
Which condition must be satisfied for two relations $R$ and $S$ to be valid operands for relational union ($R \cup S$) and set difference ($R - S$)?	Identical cardinality: both tables must contain the exact same number of tuples.	Union compatibility: both relations must have the same number of attributes with compatible data domains.	Referential coupling: one table must declare a foreign key referencing the other.	Key parity: both relations must share identical primary key column names.	B	Union compatibility (type compatibility) requires identical degree and pairwise compatible attribute domains.	Databases	Relational Databases	Relational algebra	Intermediate	Elements	computing, databases, relational-databases, relational-algebra				
Relation $R$ contains $|R| = 20$ tuples and relation $S$ contains $|S| = 15$ tuples. Calculate the exact cardinality of their Cartesian product $R \times S$.	35 tuples	150 tuples	300 tuples	3000 tuples	C	**Given:** $|R| = 20$, $|S| = 15$. **Formula:** $|R \times S| = |R| \times |S|$ **Calculation:** $|R \times S| = 20 \times 15 = 300\text{ tuples}$. **Answer:** 300 tuples	Databases	Relational Databases	Relational algebra	Hard	Solving	computing, databases, relational-databases, relational-algebra				
Relation $R(A, B)$ has $|R| = 10$ tuples and relation $S(B, C)$ has $|S| = 6$ tuples. If every tuple in $R$ matches every tuple in $S$ on attribute $B$, calculate the maximum possible cardinality of $R \bowtie S$.	60 tuples	16 tuples	6 tuples	10 tuples	A	**Given:** $|R| = 10$, $|S| = 6$, all tuples share an identical value on join attribute $B$. **Formula:** $\max |R \bowtie S| = |R| \times |S|$ when all join keys match. **Calculation:** $\max |R \bowtie S| = 10 \times 6 = 60\text{ tuples}$. **Answer:** 60 tuples	Databases	Relational Databases	Relational algebra	Hard	Solving	computing, databases, relational-databases, relational-algebra				
Union-compatible relations $R$ and $S$ have $|R| = 40$ tuples and $|S| = 25$ tuples. If their intersection contains $|R \cap S| = 10$ tuples, calculate the cardinality of $R \cup S$.	65 tuples	50 tuples	55 tuples	75 tuples	C	**Given:** $|R| = 40$, $|S| = 25$, $|R \cap S| = 10$. **Formula:** $|R \cup S| = |R| + |S| - |R \cap S|$ **Calculation:** $|R \cup S| = 40 + 25 - 10 = 65 - 10 = 55\text{ tuples}$. **Answer:** 55 tuples	Databases	Relational Databases	Relational algebra	Hard	Solving	computing, databases, relational-databases, relational-algebra				
Relation $R$ contains $|R| = 20$ tuples and relation $S$ contains $|S| = 15$ tuples. Calculate the exact cardinality of their Cartesian product $R \times S$.	35 tuples	150 tuples	300 tuples	3000 tuples	C	**Given:** $|R| = 20$, $|S| = 15$. **Formula:** $|R \times S| = |R| \times |S|$ **Calculation:** $|R \times S| = 20 \times 15 = 300\text{ tuples}$. **Answer:** 300 tuples	Databases	Relational Databases	Relational algebra	Intermediate	Solving	computing, databases, relational-databases, relational-algebra				
Relation $R(A, B)$ has $|R| = 10$ tuples and relation $S(B, C)$ has $|S| = 6$ tuples. If every tuple in $R$ matches every tuple in $S$ on attribute $B$, calculate the maximum possible cardinality of $R \bowtie S$.	10 tuples	16 tuples	6 tuples	60 tuples	D	**Given:** $|R| = 10$, $|S| = 6$, all tuples share an identical value on join attribute $B$. **Formula:** $\max |R \bowtie S| = |R| \times |S|$ when all join keys match. **Calculation:** $\max |R \bowtie S| = 10 \times 6 = 60\text{ tuples}$. **Answer:** 60 tuples	Databases	Relational Databases	Relational algebra	Intermediate	Solving	computing, databases, relational-databases, relational-algebra				
Union-compatible relations $R$ and $S$ have $|R| = 40$ tuples and $|S| = 25$ tuples. If their intersection contains $|R \cap S| = 10$ tuples, calculate the cardinality of $R \cup S$.	65 tuples	50 tuples	75 tuples	55 tuples	D	**Given:** $|R| = 40$, $|S| = 25$, $|R \cap S| = 10$. **Formula:** $|R \cup S| = |R| + |S| - |R \cap S|$ **Calculation:** $|R \cup S| = 40 + 25 - 10 = 65 - 10 = 55\text{ tuples}$. **Answer:** 55 tuples	Databases	Relational Databases	Relational algebra	Intermediate	Solving	computing, databases, relational-databases, relational-algebra				
What significant operational constraint or risk governs intentional database denormalization?	It eliminates the need for primary keys across all physical tables.	It automatically converts relational schemas into non-relational document trees.	It guarantees zero data redundancy while strictly doubling write throughput.	It accelerates read query performance by avoiding joins, but increases storage and risks update anomalies.	D	Denormalization deliberately introduces redundancy into a normalized schema to improve read latency at the expense of write overhead and anomaly risks.	Databases	Relational Databases	Schema design	Intermediate	Elements	computing, databases, relational-databases, schema-design				
Why might a database designer choose a surrogate primary key over a multi-column composite natural key?	Surrogate keys mathematically prevent concurrent write deadlocks during transactions.	Surrogate keys ensure that the table automatically satisfies Boyce-Codd Normal Form.	Surrogate keys provide compact, immutable integer identifiers that simplify foreign keys and optimize index lookups.	Surrogate keys eliminate the necessity of creating UNIQUE constraints on business keys.	C	Surrogate keys are compact, stable, and shield relational foreign key structures from changes in real-world business keys.	Databases	Relational Databases	Schema design	Intermediate	Elements	computing, databases, relational-databases, schema-design				
What significant operational constraint or risk governs intentional database denormalization?	It eliminates the need for primary keys across all physical tables.	It automatically converts relational schemas into non-relational document trees.	It guarantees zero data redundancy while strictly doubling write throughput.	It accelerates read query performance by avoiding joins, but increases storage and risks update anomalies.	D	Denormalization deliberately introduces redundancy into a normalized schema to improve read latency at the expense of write overhead and anomaly risks.	Databases	Relational Databases	Schema design	Intermediate	Elements	computing, databases, relational-databases, schema-design				
Why might a database designer choose a surrogate primary key over a multi-column composite natural key?	Surrogate keys mathematically prevent concurrent write deadlocks during transactions.	Surrogate keys ensure that the table automatically satisfies Boyce-Codd Normal Form.	Surrogate keys provide compact, immutable integer identifiers that simplify foreign keys and optimize index lookups.	Surrogate keys eliminate the necessity of creating UNIQUE constraints on business keys.	C	Surrogate keys are compact, stable, and shield relational foreign key structures from changes in real-world business keys.	Databases	Relational Databases	Schema design	Intermediate	Elements	computing, databases, relational-databases, schema-design				
In relational database theory, what distinguishes a candidate key from a superkey?	A candidate key is a minimal superkey containing no redundant attributes.	A superkey is selected by the database administrator to be the primary index.	A candidate key allows null values whereas a superkey strictly prohibits them.	A candidate key must always consist of exactly one single attribute column.	A	A superkey uniquely identifies tuples; a candidate key is a minimal superkey such that no proper subset uniquely identifies tuples.	Databases	Relational Databases	Tables and keys	Intermediate	Elements	computing, databases, relational-databases, tables-and-keys				
What is the relational role of a foreign key defined on table `Orders` referencing table `Customers`?	It enforces referential integrity by requiring order rows to point to valid customer primary keys or contain NULL.	It automatically clusters customer data on the exact same physical disk sector as orders.	It prohibits users from executing SELECT joins between Orders and Customers.	It creates an indexed composite primary key across both tables simultaneously.	A	Foreign keys link a child table attribute to a candidate key of a parent table, maintaining referential integrity.	Databases	Relational Databases	Tables and keys	Basic	Elements	computing, databases, relational-databases, tables-and-keys				
In relational database theory, what distinguishes a candidate key from a superkey?	A candidate key is a minimal superkey containing no redundant attributes.	A superkey is selected by the database administrator to be the primary index.	A candidate key allows null values whereas a superkey strictly prohibits them.	A candidate key must always consist of exactly one single attribute column.	A	A superkey uniquely identifies tuples; a candidate key is a minimal superkey such that no proper subset uniquely identifies tuples.	Databases	Relational Databases	Tables and keys	Intermediate	Elements	computing, databases, relational-databases, tables-and-keys				
What is the relational role of a foreign key defined on table `Orders` referencing table `Customers`?	It enforces referential integrity by requiring order rows to point to valid customer primary keys or contain NULL.	It automatically clusters customer data on the exact same physical disk sector as orders.	It prohibits users from executing SELECT joins between Orders and Customers.	It creates an indexed composite primary key across both tables simultaneously.	A	Foreign keys link a child table attribute to a candidate key of a parent table, maintaining referential integrity.	Databases	Relational Databases	Tables and keys	Basic	Elements	computing, databases, relational-databases, tables-and-keys				
What is the fundamental difference between a standard virtual view and a materialized view in a relational DBMS?	A standard view stores data on solid-state drives, while a materialized view stores data in RAM.	A standard view allows write operations, while a materialized view is strictly read-only by hardware.	A standard view is a saved query executed dynamically on access, while a materialized view physically stores query results on disk.	A standard view requires external Python triggers, while a materialized view uses SQL indexes.	C	Standard views compute results on-the-fly; materialized views persist precomputed results physically, requiring refresh on data changes.	Databases	Relational Databases	Views	Intermediate	Elements	computing, databases, relational-databases, views				
Which condition generally permits an SQL view to be directly updatable via INSERT or UPDATE statements?	The view is defined on a single base table without aggregate functions, GROUP BY, DISTINCT, or UNION clauses.	The view joins at least three base tables using FULL OUTER JOIN syntax.	The view includes a HAVING clause filtering on subquery aggregates.	The view uses window functions across multiple partition boundaries.	A	An updatable view must have a 1-to-1 unambiguous mapping to tuples in a single underlying base table, prohibiting aggregates and set operators.	Databases	Relational Databases	Views	Intermediate	Elements	computing, databases, relational-databases, views				
What is the fundamental difference between a standard virtual view and a materialized view in a relational DBMS?	A standard view stores data on solid-state drives, while a materialized view stores data in RAM.	A standard view allows write operations, while a materialized view is strictly read-only by hardware.	A standard view is a saved query executed dynamically on access, while a materialized view physically stores query results on disk.	A standard view requires external Python triggers, while a materialized view uses SQL indexes.	C	Standard views compute results on-the-fly; materialized views persist precomputed results physically, requiring refresh on data changes.	Databases	Relational Databases	Views	Intermediate	Elements	computing, databases, relational-databases, views				
Which condition generally permits an SQL view to be directly updatable via INSERT or UPDATE statements?	The view is defined on a single base table without aggregate functions, GROUP BY, DISTINCT, or UNION clauses.	The view joins at least three base tables using FULL OUTER JOIN syntax.	The view includes a HAVING clause filtering on subquery aggregates.	The view uses window functions across multiple partition boundaries.	A	An updatable view must have a 1-to-1 unambiguous mapping to tuples in a single underlying base table, prohibiting aggregates and set operators.	Databases	Relational Databases	Views	Intermediate	Elements	computing, databases, relational-databases, views				
Table `Scores` has column `pts` with values [10, 20, NULL, 30]. Calculate the result of query `SELECT AVG(pts) FROM Scores;`.	NULL	60.0	15.0	20.0	D	**Given:** Column values: [10, 20, NULL, 30]. **Formula:** AVG ignores NULL values: $\text{AVG} = \frac{\sum \text{non-null values}}{\text{count of non-null values}}$. **Calculation:** Non-null values are 10, 20, 30. Sum $= 10 + 20 + 30 = 60$. Count $= 3$. Average $= 60 / 3 = 20.0$. **Answer:** 20.0	Databases	SQL	Aggregation	Hard	Solving	computing, databases, sql, aggregation				
What is the key functional difference between `COUNT(*)` and `COUNT(column_name)` in an SQL aggregation query?	COUNT(*) counts only distinct rows, while COUNT(column_name) counts all duplicates.	COUNT(*) returns a decimal float, while COUNT(column_name) returns a 64-bit integer.	COUNT(*) operates on indexed columns only, while COUNT(column_name) scans raw tables.	COUNT(*) counts all rows including NULLs, while COUNT(column_name) counts only rows where the column is NOT NULL.	D	`COUNT(*)` tallies physical rows regardless of content; `COUNT(column)` evaluates column expressions, skipping null entries.	Databases	SQL	Aggregation	Intermediate	Elements	computing, databases, sql, aggregation				
Table `Data` contains 4 rows with column `val` having values [4, 6, NULL, 8]. Calculate the integer result of expression `COUNT(*) - COUNT(val)`.	3	1	2	0	B	**Given:** Values: [4, 6, NULL, 8]. **Formula:** Difference equals the number of rows where `val` is NULL. **Calculation:** Total rows: $\text{COUNT}(*) = 4$. Non-null count: $\text{COUNT}(val) = 3$. Difference $= 4 - 3 = 1$. **Answer:** 1	Databases	SQL	Aggregation	Intermediate	Solving	computing, databases, sql, aggregation				
What does `SELECT COUNT(*) FROM EmptyTable;` return when executed against a table containing zero rows?	A single row containing the integer value 0.	A database runtime division-by-zero exception.	A single row containing a NULL value.	An empty result set containing zero rows.	A	Aggregate queries without GROUP BY always return exactly one row; for an empty table, COUNT(*) evaluates to 0.	Databases	SQL	Aggregation	Intermediate	Elements	computing, databases, sql, aggregation				
What is the key functional difference between `COUNT(*)` and `COUNT(column_name)` in an SQL aggregation query?	COUNT(*) counts only distinct rows, while COUNT(column_name) counts all duplicates.	COUNT(*) returns a decimal float, while COUNT(column_name) returns a 64-bit integer.	COUNT(*) operates on indexed columns only, while COUNT(column_name) scans raw tables.	COUNT(*) counts all rows including NULLs, while COUNT(column_name) counts only rows where the column is NOT NULL.	D	`COUNT(*)` tallies physical rows regardless of content; `COUNT(column)` evaluates column expressions, skipping null entries.	Databases	SQL	Aggregation	Intermediate	Elements	computing, databases, sql, aggregation				
What does `SELECT COUNT(*) FROM EmptyTable;` return when executed against a table containing zero rows?	A single row containing the integer value 0.	A database runtime division-by-zero exception.	A single row containing a NULL value.	An empty result set containing zero rows.	A	Aggregate queries without GROUP BY always return exactly one row; for an empty table, COUNT(*) evaluates to 0.	Databases	SQL	Aggregation	Intermediate	Elements	computing, databases, sql, aggregation				
Table `Scores` has column `pts` with values [10, 20, NULL, 30]. Calculate the result of query `SELECT AVG(pts) FROM Scores;`.	NULL	60.0	15.0	20.0	D	**Given:** Column values: [10, 20, NULL, 30]. **Formula:** AVG ignores NULL values: $\text{AVG} = \frac{\sum \text{non-null values}}{\text{count of non-null values}}$. **Calculation:** Non-null values are 10, 20, 30. Sum $= 10 + 20 + 30 = 60$. Count $= 3$. Average $= 60 / 3 = 20.0$. **Answer:** 20.0	Databases	SQL	Aggregation	Hard	Solving	computing, databases, sql, aggregation				
Table `Data` contains 4 rows with column `val` having values [4, 6, NULL, 8]. Calculate the integer result of expression `COUNT(*) - COUNT(val)`.	3	1	2	0	B	**Given:** Values: [4, 6, NULL, 8]. **Formula:** Difference equals the number of rows where `val` is NULL. **Calculation:** Total rows: $\text{COUNT}(*) = 4$. Non-null count: $\text{COUNT}(val) = 3$. Difference $= 4 - 3 = 1$. **Answer:** 1	Databases	SQL	Aggregation	Hard	Solving	computing, databases, sql, aggregation				
Table `Scores` has column `pts` with values [10, 20, NULL, 30]. Calculate the result of query `SELECT AVG(pts) FROM Scores;`.	NULL	20.0	15.0	60.0	B	**Given:** Column values: [10, 20, NULL, 30]. **Formula:** AVG ignores NULL values: $\text{AVG} = \frac{\sum \text{non-null values}}{\text{count of non-null values}}$. **Calculation:** Non-null values are 10, 20, 30. Sum $= 10 + 20 + 30 = 60$. Count $= 3$. Average $= 60 / 3 = 20.0$. **Answer:** 20.0	Databases	SQL	Aggregation	Intermediate	Solving	computing, databases, sql, aggregation				
Table `Data` contains 4 rows with column `val` having values [4, 6, NULL, 8]. Calculate the integer result of expression `COUNT(*) - COUNT(val)`.	3	1	2	0	B	**Given:** Values: [4, 6, NULL, 8]. **Formula:** Difference equals the number of rows where `val` is NULL. **Calculation:** Total rows: $\text{COUNT}(*) = 4$. Non-null count: $\text{COUNT}(val) = 3$. Difference $= 4 - 3 = 1$. **Answer:** 1	Databases	SQL	Aggregation	Intermediate	Solving	computing, databases, sql, aggregation				
Table created as: `CREATE TABLE Emp (id INT PRIMARY KEY, sal INT CHECK (sal >= 1000));`. Four sequential inserts are executed: (1, 1500), (2, 800), (1, 2000), (3, 1200). How many rows are successfully stored?	4 rows	1 row	2 rows	3 rows	C	**Given:** PRIMARY KEY on id, CHECK constraint sal >= 1000. Inserts: (1, 1500), (2, 800), (1, 2000), (3, 1200). **Formula:** Check constraints must evaluate to true, and primary keys must remain unique. **Calculation:** (1, 1500): valid, inserted. (2, 800): violates CHECK (800 < 1000), rejected. (1, 2000): duplicate PK id=1, rejected. (3, 1200): valid, inserted. Total stored = 2 rows. **Answer:** 2 rows	Databases	SQL	Data definition	Hard	Solving	computing, databases, sql, data-definition				
How does the DDL command `TRUNCATE TABLE` fundamentally differ from the DML command `DELETE FROM table`?	TRUNCATE deallocates data pages with minimal logging and cannot filter by WHERE; DELETE removes rows individually with full transaction logging.	TRUNCATE requires a WHERE clause; DELETE operates only on entire tables.	TRUNCATE fires individual row-level triggers; DELETE bypasses all database triggers.	TRUNCATE deletes the table schema definition; DELETE retains the schema definition.	A	TRUNCATE is a fast DDL operation that deallocates storage pages directly without firing row triggers or logging row-by-row deletions.	Databases	SQL	Data definition	Intermediate	Elements	computing, databases, sql, data-definition				
Table `Orders` has 12 rows referencing `Customers` with `ON DELETE CASCADE`. A DBA executes `DELETE FROM Customers WHERE id IN (1, 2);`. If customer 1 has 4 orders and customer 2 has 2 orders, how many orders remain?	10 orders	8 orders	0 orders	6 orders	D	**Given:** Initial orders = 12. Customer 1 has 4 orders, Customer 2 has 2 orders. Foreign key has ON DELETE CASCADE. **Formula:** Remaining orders = Initial orders - Cascaded order deletions. **Calculation:** Deleting customers 1 and 2 cascades to delete $4 + 2 = 6$ child order rows. Remaining orders $= 12 - 6 = 6$ orders. **Answer:** 6 orders	Databases	SQL	Data definition	Hard	Solving	computing, databases, sql, data-definition				
Which operation CANNOT be performed using the standard SQL `ALTER TABLE` statement?	Adding a new column with a DEFAULT value.	Dropping an existing column from the table definition.	Switching the database storage engine while preserving uncommitted client transactions.	Adding a new FOREIGN KEY constraint referencing an existing table.	C	`ALTER TABLE` modifies schema definitions (columns, constraints, indexes); transactional state management is independent of schema DDL.	Databases	SQL	Data definition	Intermediate	Elements	computing, databases, sql, data-definition				
How does the DDL command `TRUNCATE TABLE` fundamentally differ from the DML command `DELETE FROM table`?	TRUNCATE deallocates data pages with minimal logging and cannot filter by WHERE; DELETE removes rows individually with full transaction logging.	TRUNCATE requires a WHERE clause; DELETE operates only on entire tables.	TRUNCATE fires individual row-level triggers; DELETE bypasses all database triggers.	TRUNCATE deletes the table schema definition; DELETE retains the schema definition.	A	TRUNCATE is a fast DDL operation that deallocates storage pages directly without firing row triggers or logging row-by-row deletions.	Databases	SQL	Data definition	Intermediate	Elements	computing, databases, sql, data-definition				
Which operation CANNOT be performed using the standard SQL `ALTER TABLE` statement?	Adding a new column with a DEFAULT value.	Dropping an existing column from the table definition.	Switching the database storage engine while preserving uncommitted client transactions.	Adding a new FOREIGN KEY constraint referencing an existing table.	C	`ALTER TABLE` modifies schema definitions (columns, constraints, indexes); transactional state management is independent of schema DDL.	Databases	SQL	Data definition	Intermediate	Elements	computing, databases, sql, data-definition				
Table created as: `CREATE TABLE Emp (id INT PRIMARY KEY, sal INT CHECK (sal >= 1000));`. Four sequential inserts are executed: (1, 1500), (2, 800), (1, 2000), (3, 1200). How many rows are successfully stored?	4 rows	1 row	2 rows	3 rows	C	**Given:** PRIMARY KEY on id, CHECK constraint sal >= 1000. Inserts: (1, 1500), (2, 800), (1, 2000), (3, 1200). **Formula:** Check constraints must evaluate to true, and primary keys must remain unique. **Calculation:** (1, 1500): valid, inserted. (2, 800): violates CHECK (800 < 1000), rejected. (1, 2000): duplicate PK id=1, rejected. (3, 1200): valid, inserted. Total stored = 2 rows. **Answer:** 2 rows	Databases	SQL	Data definition	Hard	Solving	computing, databases, sql, data-definition				
Table `Orders` has 12 rows referencing `Customers` with `ON DELETE CASCADE`. A DBA executes `DELETE FROM Customers WHERE id IN (1, 2);`. If customer 1 has 4 orders and customer 2 has 2 orders, how many orders remain?	10 orders	8 orders	0 orders	6 orders	D	**Given:** Initial orders = 12. Customer 1 has 4 orders, Customer 2 has 2 orders. Foreign key has ON DELETE CASCADE. **Formula:** Remaining orders = Initial orders - Cascaded order deletions. **Calculation:** Deleting customers 1 and 2 cascades to delete $4 + 2 = 6$ child order rows. Remaining orders $= 12 - 6 = 6$ orders. **Answer:** 6 orders	Databases	SQL	Data definition	Hard	Solving	computing, databases, sql, data-definition				
Table created as: `CREATE TABLE Emp (id INT PRIMARY KEY, sal INT CHECK (sal >= 1000));`. Four sequential inserts are executed: (1, 1500), (2, 800), (1, 2000), (3, 1200). How many rows are successfully stored?	4 rows	1 row	2 rows	3 rows	C	**Given:** PRIMARY KEY on id, CHECK constraint sal >= 1000. Inserts: (1, 1500), (2, 800), (1, 2000), (3, 1200). **Formula:** Check constraints must evaluate to true, and primary keys must remain unique. **Calculation:** (1, 1500): valid, inserted. (2, 800): violates CHECK (800 < 1000), rejected. (1, 2000): duplicate PK id=1, rejected. (3, 1200): valid, inserted. Total stored = 2 rows. **Answer:** 2 rows	Databases	SQL	Data definition	Intermediate	Solving	computing, databases, sql, data-definition				
Table `Orders` has 12 rows referencing `Customers` with `ON DELETE CASCADE`. A DBA executes `DELETE FROM Customers WHERE id IN (1, 2);`. If customer 1 has 4 orders and customer 2 has 2 orders, how many orders remain?	10 orders	6 orders	0 orders	8 orders	B	**Given:** Initial orders = 12. Customer 1 has 4 orders, Customer 2 has 2 orders. Foreign key has ON DELETE CASCADE. **Formula:** Remaining orders = Initial orders - Cascaded order deletions. **Calculation:** Deleting customers 1 and 2 cascades to delete $4 + 2 = 6$ child order rows. Remaining orders $= 12 - 6 = 6$ orders. **Answer:** 6 orders	Databases	SQL	Data definition	Intermediate	Solving	computing, databases, sql, data-definition				
Table `Sales(dept, amt)` contains rows: ('HR', 100), ('HR', 200), ('IT', 150), ('IT', 50), ('Sales', 300). Query: `SELECT dept, SUM(amt) FROM Sales GROUP BY dept HAVING SUM(amt) >= 200;`. How many rows are returned?	4 rows	2 rows	3 rows	1 row	C	**Given:** HR: [100, 200], IT: [150, 50], Sales: [300]. HAVING SUM(amt) >= 200. **Formula:** Compute SUM per group, filter groups where SUM $\ge 200$. **Calculation:** HR sum $= 100 + 200 = 300$ ($\ge 200$). IT sum $= 150 + 50 = 200$ ($\ge 200$). Sales sum $= 300$ ($\ge 200$). All 3 groups satisfy the HAVING predicate. Exactly 3 rows are returned. **Answer:** 3 rows	Databases	SQL	GROUP BY and HAVING	Hard	Solving	computing, databases, sql, group-by-and-having				
Why does SQL require aggregate conditions such as `COUNT(*) > 5` to be placed in the HAVING clause rather than the WHERE clause?	Because SQL syntax rules prohibit boolean operators inside the WHERE clause.	Because the WHERE clause filters rows before groups are formed, while HAVING filters after group aggregates are computed.	Because the WHERE clause can only process string comparisons and not numeric integers.	Because the HAVING clause executes inside the client application rather than the database server.	B	At the time WHERE filters rows, groups and aggregates do not yet exist; HAVING evaluates post-aggregation.	Databases	SQL	GROUP BY and HAVING	Intermediate	Elements	computing, databases, sql, group-by-and-having				
Table `Staff` has 7 rows with department column `dept`: ['IT', 'IT', 'HR', 'HR', 'HR', NULL, NULL]. How many output rows are produced by: `SELECT dept, COUNT(*) FROM Staff GROUP BY dept;`?	2 rows	4 rows	5 rows	3 rows	D	**Given:** Values: ['IT', 'IT', 'HR', 'HR', 'HR', NULL, NULL]. **Formula:** Each unique non-null value forms one group; all NULLs form exactly one group. **Calculation:** Distinct non-null departments are 'IT' (count 2) and 'HR' (count 3). Both NULL rows combine into a single NULL group (count 2). Total output groups = 3 rows. **Answer:** 3 rows	Databases	SQL	GROUP BY and HAVING	Hard	Solving	computing, databases, sql, group-by-and-having				
In a query containing `GROUP BY dept`, which column reference is valid in the `SELECT` list under the SQL standard?	Any column that appears in the GROUP BY clause or is enclosed within an aggregate function.	Any unaggregated column from any table in the schema.	Only columns that possess unique primary key constraints.	Only columns defined with numeric floating-point datatypes.	A	Every non-aggregate expression in the SELECT list must be functionally dependent on or part of the GROUP BY clause.	Databases	SQL	GROUP BY and HAVING	Intermediate	Elements	computing, databases, sql, group-by-and-having				
Why does SQL require aggregate conditions such as `COUNT(*) > 5` to be placed in the HAVING clause rather than the WHERE clause?	Because SQL syntax rules prohibit boolean operators inside the WHERE clause.	Because the WHERE clause filters rows before groups are formed, while HAVING filters after group aggregates are computed.	Because the WHERE clause can only process string comparisons and not numeric integers.	Because the HAVING clause executes inside the client application rather than the database server.	B	At the time WHERE filters rows, groups and aggregates do not yet exist; HAVING evaluates post-aggregation.	Databases	SQL	GROUP BY and HAVING	Intermediate	Elements	computing, databases, sql, group-by-and-having				
In a query containing `GROUP BY dept`, which column reference is valid in the `SELECT` list under the SQL standard?	Any column that appears in the GROUP BY clause or is enclosed within an aggregate function.	Any unaggregated column from any table in the schema.	Only columns that possess unique primary key constraints.	Only columns defined with numeric floating-point datatypes.	A	Every non-aggregate expression in the SELECT list must be functionally dependent on or part of the GROUP BY clause.	Databases	SQL	GROUP BY and HAVING	Intermediate	Elements	computing, databases, sql, group-by-and-having				
Table `Sales(dept, amt)` contains rows: ('HR', 100), ('HR', 200), ('IT', 150), ('IT', 50), ('Sales', 300). Query: `SELECT dept, SUM(amt) FROM Sales GROUP BY dept HAVING SUM(amt) >= 200;`. How many rows are returned?	4 rows	2 rows	3 rows	1 row	C	**Given:** HR: [100, 200], IT: [150, 50], Sales: [300]. HAVING SUM(amt) >= 200. **Formula:** Compute SUM per group, filter groups where SUM $\ge 200$. **Calculation:** HR sum $= 100 + 200 = 300$ ($\ge 200$). IT sum $= 150 + 50 = 200$ ($\ge 200$). Sales sum $= 300$ ($\ge 200$). All 3 groups satisfy the HAVING predicate. Exactly 3 rows are returned. **Answer:** 3 rows	Databases	SQL	GROUP BY and HAVING	Hard	Solving	computing, databases, sql, group-by-and-having				
Table `Staff` has 7 rows with department column `dept`: ['IT', 'IT', 'HR', 'HR', 'HR', NULL, NULL]. How many output rows are produced by: `SELECT dept, COUNT(*) FROM Staff GROUP BY dept;`?	2 rows	4 rows	5 rows	3 rows	D	**Given:** Values: ['IT', 'IT', 'HR', 'HR', 'HR', NULL, NULL]. **Formula:** Each unique non-null value forms one group; all NULLs form exactly one group. **Calculation:** Distinct non-null departments are 'IT' (count 2) and 'HR' (count 3). Both NULL rows combine into a single NULL group (count 2). Total output groups = 3 rows. **Answer:** 3 rows	Databases	SQL	GROUP BY and HAVING	Hard	Solving	computing, databases, sql, group-by-and-having				
Table `Sales(dept, amt)` contains rows: ('HR', 100), ('HR', 200), ('IT', 150), ('IT', 50), ('Sales', 300). Query: `SELECT dept, SUM(amt) FROM Sales GROUP BY dept HAVING SUM(amt) >= 200;`. How many rows are returned?	4 rows	2 rows	3 rows	1 row	C	**Given:** HR: [100, 200], IT: [150, 50], Sales: [300]. HAVING SUM(amt) >= 200. **Formula:** Compute SUM per group, filter groups where SUM $\ge 200$. **Calculation:** HR sum $= 100 + 200 = 300$ ($\ge 200$). IT sum $= 150 + 50 = 200$ ($\ge 200$). Sales sum $= 300$ ($\ge 200$). All 3 groups satisfy the HAVING predicate. Exactly 3 rows are returned. **Answer:** 3 rows	Databases	SQL	GROUP BY and HAVING	Intermediate	Solving	computing, databases, sql, group-by-and-having				
Table `Staff` has 7 rows with department column `dept`: ['IT', 'IT', 'HR', 'HR', 'HR', NULL, NULL]. How many output rows are produced by: `SELECT dept, COUNT(*) FROM Staff GROUP BY dept;`?	2 rows	3 rows	5 rows	4 rows	B	**Given:** Values: ['IT', 'IT', 'HR', 'HR', 'HR', NULL, NULL]. **Formula:** Each unique non-null value forms one group; all NULLs form exactly one group. **Calculation:** Distinct non-null departments are 'IT' (count 2) and 'HR' (count 3). Both NULL rows combine into a single NULL group (count 2). Total output groups = 3 rows. **Answer:** 3 rows	Databases	SQL	GROUP BY and HAVING	Intermediate	Solving	computing, databases, sql, group-by-and-having				
Why can a relational database table have at most one clustered index?	Because SQL standards limit index definitions to single-column integer keys.	Because database buffer managers can only allocate one B-tree in memory.	Because secondary indexes automatically delete clustered indexes upon creation.	Because a clustered index dictates the physical sorting order of the data rows on disk.	D	A table's physical data rows can only be arranged in one physical sequence on disk, limiting clustered indexes to one per table.	Databases	SQL	Indexes in SQL	Intermediate	Elements	computing, databases, sql, indexes-in-sql				
Under the leftmost prefix rule for composite index `(col_a, col_b, col_c)`, which query predicate can effectively utilize this index?	WHERE col_c = 20	WHERE col_b = 10 AND col_c = 20	WHERE col_b = 10	WHERE col_a = 5 AND col_b = 10	D	A composite index can only satisfy searches matching a leading prefix of index columns: `(col_a)`, `(col_a, col_b)`, or `(col_a, col_b, col_c)`.	Databases	SQL	Indexes in SQL	Basic	Elements	computing, databases, sql, indexes-in-sql				
Why can a relational database table have at most one clustered index?	Because SQL standards limit index definitions to single-column integer keys.	Because database buffer managers can only allocate one B-tree in memory.	Because secondary indexes automatically delete clustered indexes upon creation.	Because a clustered index dictates the physical sorting order of the data rows on disk.	D	A table's physical data rows can only be arranged in one physical sequence on disk, limiting clustered indexes to one per table.	Databases	SQL	Indexes in SQL	Intermediate	Elements	computing, databases, sql, indexes-in-sql				
Under the leftmost prefix rule for composite index `(col_a, col_b, col_c)`, which query predicate can effectively utilize this index?	WHERE col_c = 20	WHERE col_b = 10 AND col_c = 20	WHERE col_b = 10	WHERE col_a = 5 AND col_b = 10	D	A composite index can only satisfy searches matching a leading prefix of index columns: `(col_a)`, `(col_a, col_b)`, or `(col_a, col_b, col_c)`.	Databases	SQL	Indexes in SQL	Basic	Elements	computing, databases, sql, indexes-in-sql				
Table A has rows with key values [1, 1, 2] and Table B has rows with key values [1, 1, 3]. How many rows are returned by `SELECT * FROM A INNER JOIN B ON A.key = B.key;`?	5 rows	2 rows	4 rows	1 row	C	**Given:** A.key = [1, 1, 2], B.key = [1, 1, 3]. **Formula:** Number of matching rows = $\sum_{k} (\text{count of } k \text{ in A}) \times (\text{count of } k \text{ in B})$. **Calculation:** Key 1 appears 2 times in A and 2 times in B. Output rows for key 1 = $2 \times 2 = 4$. Keys 2 and 3 do not match. Total inner join rows = 4. **Answer:** 4 rows	Databases	SQL	Joins	Hard	Solving	computing, databases, sql, joins				
What is the operational effect of adding a filter condition on the right table in the WHERE clause instead of the ON clause of a LEFT JOIN?	It replaces all non-matching left table rows with zeros instead of NULLs.	It accelerates query execution without altering the returned result set.	It filters out rows where right-table attributes are NULL, effectively converting the LEFT JOIN into an INNER JOIN.	It causes the query optimizer to throw an invalid syntax error.	C	Because WHERE evaluates after the outer join, testing `WHERE B.col = 'value'` evaluates to UNKNOWN for generated NULLs, discarding unmatched left rows.	Databases	SQL	Joins	Intermediate	Elements	computing, databases, sql, joins				
Table A has 3 rows (keys 1, 2, 3). Table B has 2 rows (key 1 appearing twice). Calculate the row count produced by `SELECT * FROM A LEFT JOIN B ON A.id = B.id;`.	3 rows	4 rows	5 rows	2 rows	B	**Given:** A.id = [1, 2, 3], B.id = [1, 1]. **Formula:** Rows = (matches for key 1) + (unmatched key 2) + (unmatched key 3). **Calculation:** Key 1 matches 2 rows in B: $1 \times 2 = 2$ rows. Key 2 has no match in B: 1 row with NULLs. Key 3 has no match in B: 1 row with NULLs. Total = $2 + 1 + 1 = 4$ rows. **Answer:** 4 rows	Databases	SQL	Joins	Hard	Solving	computing, databases, sql, joins				
When does an SQL CROSS JOIN produce the exact same result set as an INNER JOIN?	When both tables are indexed using clustered B-trees.	When all attributes in both tables contain strictly non-null values.	When the INNER JOIN has a trivial join predicate that is always true (such as ON 1=1).	When both joined tables possess identical numbers of primary key columns.	C	A CROSS JOIN computes the unconstrained Cartesian product; an INNER JOIN with condition `ON 1=1` matches all row pairs identically.	Databases	SQL	Joins	Intermediate	Elements	computing, databases, sql, joins				
What is the operational effect of adding a filter condition on the right table in the WHERE clause instead of the ON clause of a LEFT JOIN?	It replaces all non-matching left table rows with zeros instead of NULLs.	It accelerates query execution without altering the returned result set.	It filters out rows where right-table attributes are NULL, effectively converting the LEFT JOIN into an INNER JOIN.	It causes the query optimizer to throw an invalid syntax error.	C	Because WHERE evaluates after the outer join, testing `WHERE B.col = 'value'` evaluates to UNKNOWN for generated NULLs, discarding unmatched left rows.	Databases	SQL	Joins	Intermediate	Elements	computing, databases, sql, joins				
When does an SQL CROSS JOIN produce the exact same result set as an INNER JOIN?	When both tables are indexed using clustered B-trees.	When all attributes in both tables contain strictly non-null values.	When the INNER JOIN has a trivial join predicate that is always true (such as ON 1=1).	When both joined tables possess identical numbers of primary key columns.	C	A CROSS JOIN computes the unconstrained Cartesian product; an INNER JOIN with condition `ON 1=1` matches all row pairs identically.	Databases	SQL	Joins	Intermediate	Elements	computing, databases, sql, joins				
Table A has rows with key values [1, 1, 2] and Table B has rows with key values [1, 1, 3]. How many rows are returned by `SELECT * FROM A INNER JOIN B ON A.key = B.key;`?	5 rows	2 rows	4 rows	1 row	C	**Given:** A.key = [1, 1, 2], B.key = [1, 1, 3]. **Formula:** Number of matching rows = $\sum_{k} (\text{count of } k \text{ in A}) \times (\text{count of } k \text{ in B})$. **Calculation:** Key 1 appears 2 times in A and 2 times in B. Output rows for key 1 = $2 \times 2 = 4$. Keys 2 and 3 do not match. Total inner join rows = 4. **Answer:** 4 rows	Databases	SQL	Joins	Hard	Solving	computing, databases, sql, joins				
Table A has 3 rows (keys 1, 2, 3). Table B has 2 rows (key 1 appearing twice). Calculate the row count produced by `SELECT * FROM A LEFT JOIN B ON A.id = B.id;`.	3 rows	4 rows	5 rows	2 rows	B	**Given:** A.id = [1, 2, 3], B.id = [1, 1]. **Formula:** Rows = (matches for key 1) + (unmatched key 2) + (unmatched key 3). **Calculation:** Key 1 matches 2 rows in B: $1 \times 2 = 2$ rows. Key 2 has no match in B: 1 row with NULLs. Key 3 has no match in B: 1 row with NULLs. Total = $2 + 1 + 1 = 4$ rows. **Answer:** 4 rows	Databases	SQL	Joins	Hard	Solving	computing, databases, sql, joins				
Table A has rows with key values [1, 1, 2] and Table B has rows with key values [1, 1, 3]. How many rows are returned by `SELECT * FROM A INNER JOIN B ON A.key = B.key;`?	5 rows	2 rows	4 rows	1 row	C	**Given:** A.key = [1, 1, 2], B.key = [1, 1, 3]. **Formula:** Number of matching rows = $\sum_{k} (\text{count of } k \text{ in A}) \times (\text{count of } k \text{ in B})$. **Calculation:** Key 1 appears 2 times in A and 2 times in B. Output rows for key 1 = $2 \times 2 = 4$. Keys 2 and 3 do not match. Total inner join rows = 4. **Answer:** 4 rows	Databases	SQL	Joins	Intermediate	Solving	computing, databases, sql, joins				
Table A has 3 rows (keys 1, 2, 3). Table B has 2 rows (key 1 appearing twice). Calculate the row count produced by `SELECT * FROM A LEFT JOIN B ON A.id = B.id;`.	3 rows	4 rows	5 rows	2 rows	B	**Given:** A.id = [1, 2, 3], B.id = [1, 1]. **Formula:** Rows = (matches for key 1) + (unmatched key 2) + (unmatched key 3). **Calculation:** Key 1 matches 2 rows in B: $1 \times 2 = 2$ rows. Key 2 has no match in B: 1 row with NULLs. Key 3 has no match in B: 1 row with NULLs. Total = $2 + 1 + 1 = 4$ rows. **Answer:** 4 rows	Databases	SQL	Joins	Intermediate	Solving	computing, databases, sql, joins				
Table `Products` contains column `price` with values [10, 25, 40, 15, 30]. Query: `SELECT price FROM Products WHERE price > 12 ORDER BY price DESC LIMIT 2;`. Determine the exact ordered result rows.	40, then 30	15, then 25	30, then 40	40, then 25	A	**Given:** Prices: [10, 25, 40, 15, 30]. Query filters price > 12, sorts DESC, limits to 2. **Formula:** Filter: $\{x \in \text{prices} \mid x > 12\}$. Order descending and select top 2. **Calculation:** Filtering price > 12 yields [25, 40, 15, 30]. Sorting descending produces [40, 30, 25, 15]. Applying LIMIT 2 selects [40, 30]. **Answer:** 40, then 30	Databases	SQL	SELECT queries	Hard	Solving	computing, databases, sql, select-queries				
Which sequence represents the correct conceptual order of execution for standard SQL query clauses?	FROM -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY -> LIMIT.	SELECT -> FROM -> WHERE -> GROUP BY -> HAVING -> ORDER BY -> LIMIT.	WHERE -> FROM -> GROUP BY -> HAVING -> SELECT -> LIMIT -> ORDER BY.	FROM -> SELECT -> WHERE -> ORDER BY -> GROUP BY -> HAVING -> LIMIT.	A	Conceptual processing starts with data sources (FROM), row filtering (WHERE), grouping (GROUP BY), group filtering (HAVING), projection (SELECT), sorting (ORDER BY), and paging (LIMIT).	Databases	SQL	SELECT queries	Intermediate	Elements	computing, databases, sql, select-queries				
Table `Items` contains 5 rows with values in column `val`: [5, 5, NULL, 10, NULL]. How many rows are returned by query `SELECT DISTINCT val FROM Items;`?	3 rows	2 rows	5 rows	4 rows	A	**Given:** Column values: [5, 5, NULL, 10, NULL]. **Formula:** DISTINCT treats all NULL values as equal to each other for deduplication purposes. **Calculation:** Unique non-null values are 5 and 10 (2 values). All NULLs collapse into a single distinct NULL row. Total distinct rows = 2 + 1 = 3 rows. **Answer:** 3 rows	Databases	SQL	SELECT queries	Hard	Solving	computing, databases, sql, select-queries				
In SQL pattern matching using the LIKE operator, what do the `%` and `_` wildcards respectively match?	% matches zero or more arbitrary characters, while _ matches exactly one single character.	% matches whitespace, while _ matches non-whitespace punctuation.	% matches any numeric digit, while _ matches any alphabetic letter.	% matches exactly one single character, while _ matches zero or more arbitrary characters.	A	`%` represents any string of zero or more characters; `_` represents exactly one arbitrary character.	Databases	SQL	SELECT queries	Intermediate	Elements	computing, databases, sql, select-queries				
Which sequence represents the correct conceptual order of execution for standard SQL query clauses?	FROM -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY -> LIMIT.	SELECT -> FROM -> WHERE -> GROUP BY -> HAVING -> ORDER BY -> LIMIT.	WHERE -> FROM -> GROUP BY -> HAVING -> SELECT -> LIMIT -> ORDER BY.	FROM -> SELECT -> WHERE -> ORDER BY -> GROUP BY -> HAVING -> LIMIT.	A	Conceptual processing starts with data sources (FROM), row filtering (WHERE), grouping (GROUP BY), group filtering (HAVING), projection (SELECT), sorting (ORDER BY), and paging (LIMIT).	Databases	SQL	SELECT queries	Intermediate	Elements	computing, databases, sql, select-queries				
In SQL pattern matching using the LIKE operator, what do the `%` and `_` wildcards respectively match?	% matches zero or more arbitrary characters, while _ matches exactly one single character.	% matches whitespace, while _ matches non-whitespace punctuation.	% matches any numeric digit, while _ matches any alphabetic letter.	% matches exactly one single character, while _ matches zero or more arbitrary characters.	A	`%` represents any string of zero or more characters; `_` represents exactly one arbitrary character.	Databases	SQL	SELECT queries	Intermediate	Elements	computing, databases, sql, select-queries				
Table `Products` contains column `price` with values [10, 25, 40, 15, 30]. Query: `SELECT price FROM Products WHERE price > 12 ORDER BY price DESC LIMIT 2;`. Determine the exact ordered result rows.	40, then 30	15, then 25	30, then 40	40, then 25	A	**Given:** Prices: [10, 25, 40, 15, 30]. Query filters price > 12, sorts DESC, limits to 2. **Formula:** Filter: $\{x \in \text{prices} \mid x > 12\}$. Order descending and select top 2. **Calculation:** Filtering price > 12 yields [25, 40, 15, 30]. Sorting descending produces [40, 30, 25, 15]. Applying LIMIT 2 selects [40, 30]. **Answer:** 40, then 30	Databases	SQL	SELECT queries	Hard	Solving	computing, databases, sql, select-queries				
Table `Items` contains 5 rows with values in column `val`: [5, 5, NULL, 10, NULL]. How many rows are returned by query `SELECT DISTINCT val FROM Items;`?	3 rows	2 rows	5 rows	4 rows	A	**Given:** Column values: [5, 5, NULL, 10, NULL]. **Formula:** DISTINCT treats all NULL values as equal to each other for deduplication purposes. **Calculation:** Unique non-null values are 5 and 10 (2 values). All NULLs collapse into a single distinct NULL row. Total distinct rows = 2 + 1 = 3 rows. **Answer:** 3 rows	Databases	SQL	SELECT queries	Hard	Solving	computing, databases, sql, select-queries				
Table `Products` contains column `price` with values [10, 25, 40, 15, 30]. Query: `SELECT price FROM Products WHERE price > 12 ORDER BY price DESC LIMIT 2;`. Determine the exact ordered result rows.	15, then 25	40, then 30	30, then 40	40, then 25	B	**Given:** Prices: [10, 25, 40, 15, 30]. Query filters price > 12, sorts DESC, limits to 2. **Formula:** Filter: $\{x \in \text{prices} \mid x > 12\}$. Order descending and select top 2. **Calculation:** Filtering price > 12 yields [25, 40, 15, 30]. Sorting descending produces [40, 30, 25, 15]. Applying LIMIT 2 selects [40, 30]. **Answer:** 40, then 30	Databases	SQL	SELECT queries	Intermediate	Solving	computing, databases, sql, select-queries				
Table `Items` contains 5 rows with values in column `val`: [5, 5, NULL, 10, NULL]. How many rows are returned by query `SELECT DISTINCT val FROM Items;`?	2 rows	3 rows	5 rows	4 rows	B	**Given:** Column values: [5, 5, NULL, 10, NULL]. **Formula:** DISTINCT treats all NULL values as equal to each other for deduplication purposes. **Calculation:** Unique non-null values are 5 and 10 (2 values). All NULLs collapse into a single distinct NULL row. Total distinct rows = 2 + 1 = 3 rows. **Answer:** 3 rows	Databases	SQL	SELECT queries	Intermediate	Solving	computing, databases, sql, select-queries				
Which operational advantage is provided by database stored procedures compared to sending ad-hoc raw SQL strings from application code?	Automatic conversion of disk-based relational storage into distributed memory caches.	Precompiled execution plans and reduced network traffic by executing complex multi-statement logic directly on the database server.	Guaranteed execution speeds that remain independent of table record counts.	Elimination of all schema constraints and foreign key validation overhead.	B	Stored procedures execute locally on the database server, reusing compiled plans and reducing client-server network roundtrips.	Databases	SQL	Stored procedures	Intermediate	Elements	computing, databases, sql, stored-procedures				
How does a stored procedure fundamentally differ from a user-defined function (UDF) in relational database engines?	Stored procedures can only be called from Python, while functions are native SQL.	Stored procedures are stored in RAM, while functions reside on disk.	Stored procedures can execute DDL modifications and transaction control commands; functions cannot have side-effects.	Stored procedures cannot accept input parameters, while functions can.	C	Functions return a value and must be deterministic/side-effect free to be used in SELECT clauses; procedures manage transactions and modify state.	Databases	SQL	Stored procedures	Basic	Elements	computing, databases, sql, stored-procedures				
Which operational advantage is provided by database stored procedures compared to sending ad-hoc raw SQL strings from application code?	Automatic conversion of disk-based relational storage into distributed memory caches.	Precompiled execution plans and reduced network traffic by executing complex multi-statement logic directly on the database server.	Guaranteed execution speeds that remain independent of table record counts.	Elimination of all schema constraints and foreign key validation overhead.	B	Stored procedures execute locally on the database server, reusing compiled plans and reducing client-server network roundtrips.	Databases	SQL	Stored procedures	Intermediate	Elements	computing, databases, sql, stored-procedures				
How does a stored procedure fundamentally differ from a user-defined function (UDF) in relational database engines?	Stored procedures can only be called from Python, while functions are native SQL.	Stored procedures are stored in RAM, while functions reside on disk.	Stored procedures can execute DDL modifications and transaction control commands; functions cannot have side-effects.	Stored procedures cannot accept input parameters, while functions can.	C	Functions return a value and must be deterministic/side-effect free to be used in SELECT clauses; procedures manage transactions and modify state.	Databases	SQL	Stored procedures	Basic	Elements	computing, databases, sql, stored-procedures				
Table T has rows [2, 4, 6, 8] and Table S has rows [1, 3, 5]. How many rows are returned by query: `SELECT * FROM T WHERE x IN (SELECT x FROM S WHERE x <= 5);`?	0 rows	4 rows	3 rows	2 rows	A	**Given:** T.x = [2, 4, 6, 8], S.x = [1, 3, 5]. Subquery selects S.x <= 5. **Formula:** Output is $\{x \in T \mid x \in \{1, 3, 5\}\}$. **Calculation:** Subquery returns set {1, 3, 5}. None of the elements in T [2, 4, 6, 8] match elements in {1, 3, 5}. Intersection is empty, so 0 rows are returned. **Answer:** 0 rows	Databases	SQL	Subqueries	Hard	Solving	computing, databases, sql, subqueries				
Why does the predicate `WHERE id NOT IN (SELECT parent_id FROM T)` return zero rows if the subquery returns even a single NULL value?	Because the subquery is converted into an empty string during query compilation.	Because primary key indexes are disabled whenever NOT IN is encountered.	Because SQL database engines automatically abort subqueries containing NULLs with syntax errors.	Because three-valued logic evaluates `id <> NULL` to UNKNOWN, causing the entire NOT IN boolean expression to fail.	D	`v NOT IN (1, NULL)` expands to `v <> 1 AND v <> NULL`. Because `v <> NULL` is UNKNOWN, the conjunction is never TRUE.	Databases	SQL	Subqueries	Intermediate	Elements	computing, databases, sql, subqueries				
Outer table `Employees` has 4 rows with department IDs [10, 20, 30, 40]. Table `Depts` contains active department IDs [10, 30]. How many rows are returned by: `SELECT * FROM Employees e WHERE EXISTS (SELECT 1 FROM Depts d WHERE d.id = e.dept_id);`?	3 rows	4 rows	1 row	2 rows	D	**Given:** Employees dept_ids: [10, 20, 30, 40]. Depts IDs: [10, 30]. **Formula:** EXISTS returns true if the correlated subquery produces at least one row. **Calculation:** For dept_id 10: subquery finds matching row in Depts (EXISTS is TRUE). For 20: no match (FALSE). For 30: matches (TRUE). For 40: no match (FALSE). Exactly 2 rows return TRUE. **Answer:** 2 rows	Databases	SQL	Subqueries	Hard	Solving	computing, databases, sql, subqueries				
What happens at runtime if a scalar subquery used in a SELECT clause returns more than one row?	The database randomly picks the first row and discards the rest silently.	The query converts the enclosing statement into a Cartesian CROSS JOIN.	The database automatically aggregates the values into an array string.	The query execution fails and throws a runtime cardinality violation error.	D	A scalar subquery must return at most one value; returning two or more rows violates scalar context and raises a runtime error.	Databases	SQL	Subqueries	Intermediate	Elements	computing, databases, sql, subqueries				
Why does the predicate `WHERE id NOT IN (SELECT parent_id FROM T)` return zero rows if the subquery returns even a single NULL value?	Because the subquery is converted into an empty string during query compilation.	Because primary key indexes are disabled whenever NOT IN is encountered.	Because SQL database engines automatically abort subqueries containing NULLs with syntax errors.	Because three-valued logic evaluates `id <> NULL` to UNKNOWN, causing the entire NOT IN boolean expression to fail.	D	`v NOT IN (1, NULL)` expands to `v <> 1 AND v <> NULL`. Because `v <> NULL` is UNKNOWN, the conjunction is never TRUE.	Databases	SQL	Subqueries	Intermediate	Elements	computing, databases, sql, subqueries				
What happens at runtime if a scalar subquery used in a SELECT clause returns more than one row?	The database randomly picks the first row and discards the rest silently.	The query converts the enclosing statement into a Cartesian CROSS JOIN.	The database automatically aggregates the values into an array string.	The query execution fails and throws a runtime cardinality violation error.	D	A scalar subquery must return at most one value; returning two or more rows violates scalar context and raises a runtime error.	Databases	SQL	Subqueries	Intermediate	Elements	computing, databases, sql, subqueries				
Table T has rows [2, 4, 6, 8] and Table S has rows [1, 3, 5]. How many rows are returned by query: `SELECT * FROM T WHERE x IN (SELECT x FROM S WHERE x <= 5);`?	0 rows	4 rows	3 rows	2 rows	A	**Given:** T.x = [2, 4, 6, 8], S.x = [1, 3, 5]. Subquery selects S.x <= 5. **Formula:** Output is $\{x \in T \mid x \in \{1, 3, 5\}\}$. **Calculation:** Subquery returns set {1, 3, 5}. None of the elements in T [2, 4, 6, 8] match elements in {1, 3, 5}. Intersection is empty, so 0 rows are returned. **Answer:** 0 rows	Databases	SQL	Subqueries	Hard	Solving	computing, databases, sql, subqueries				
Outer table `Employees` has 4 rows with department IDs [10, 20, 30, 40]. Table `Depts` contains active department IDs [10, 30]. How many rows are returned by: `SELECT * FROM Employees e WHERE EXISTS (SELECT 1 FROM Depts d WHERE d.id = e.dept_id);`?	3 rows	2 rows	1 row	4 rows	B	**Given:** Employees dept_ids: [10, 20, 30, 40]. Depts IDs: [10, 30]. **Formula:** EXISTS returns true if the correlated subquery produces at least one row. **Calculation:** For dept_id 10: subquery finds matching row in Depts (EXISTS is TRUE). For 20: no match (FALSE). For 30: matches (TRUE). For 40: no match (FALSE). Exactly 2 rows return TRUE. **Answer:** 2 rows	Databases	SQL	Subqueries	Hard	Solving	computing, databases, sql, subqueries				
Table T has rows [2, 4, 6, 8] and Table S has rows [1, 3, 5]. How many rows are returned by query: `SELECT * FROM T WHERE x IN (SELECT x FROM S WHERE x <= 5);`?	3 rows	4 rows	0 rows	2 rows	C	**Given:** T.x = [2, 4, 6, 8], S.x = [1, 3, 5]. Subquery selects S.x <= 5. **Formula:** Output is $\{x \in T \mid x \in \{1, 3, 5\}\}$. **Calculation:** Subquery returns set {1, 3, 5}. None of the elements in T [2, 4, 6, 8] match elements in {1, 3, 5}. Intersection is empty, so 0 rows are returned. **Answer:** 0 rows	Databases	SQL	Subqueries	Intermediate	Solving	computing, databases, sql, subqueries				
Outer table `Employees` has 4 rows with department IDs [10, 20, 30, 40]. Table `Depts` contains active department IDs [10, 30]. How many rows are returned by: `SELECT * FROM Employees e WHERE EXISTS (SELECT 1 FROM Depts d WHERE d.id = e.dept_id);`?	3 rows	4 rows	2 rows	1 row	C	**Given:** Employees dept_ids: [10, 20, 30, 40]. Depts IDs: [10, 30]. **Formula:** EXISTS returns true if the correlated subquery produces at least one row. **Calculation:** For dept_id 10: subquery finds matching row in Depts (EXISTS is TRUE). For 20: no match (FALSE). For 30: matches (TRUE). For 40: no match (FALSE). Exactly 2 rows return TRUE. **Answer:** 2 rows	Databases	SQL	Subqueries	Intermediate	Solving	computing, databases, sql, subqueries				
What is the operational consequence of issuing an SQL `ROLLBACK` command during an active transaction?	All database tables referenced by the query are permanently dropped.	All data modifications performed since the start of the transaction are completely undone.	Uncommitted changes are written to an external archive file for later retrieval.	The active database connection is abruptly severed and terminated.	B	`ROLLBACK` restores the database to its state before the transaction began, discarding all pending uncommitted changes.	Databases	SQL	Transactions in SQL	Intermediate	Elements	computing, databases, sql, transactions-in-sql				
What capability does a database `SAVEPOINT` provide within an ongoing SQL transaction?	It sets a rollback marker allowing partial transaction rollback without aborting the entire transaction.	It pauses concurrent queries across the entire database cluster.	It commits preceding statements permanently while keeping subsequent ones open.	It automatically encrypts table data using asymmetric cryptography.	A	`SAVEPOINT name` allows issuing `ROLLBACK TO SAVEPOINT name`, undoing only work performed after that marker while keeping the transaction active.	Databases	SQL	Transactions in SQL	Intermediate	Elements	computing, databases, sql, transactions-in-sql				
What is the operational consequence of issuing an SQL `ROLLBACK` command during an active transaction?	All database tables referenced by the query are permanently dropped.	All data modifications performed since the start of the transaction are completely undone.	Uncommitted changes are written to an external archive file for later retrieval.	The active database connection is abruptly severed and terminated.	B	`ROLLBACK` restores the database to its state before the transaction began, discarding all pending uncommitted changes.	Databases	SQL	Transactions in SQL	Intermediate	Elements	computing, databases, sql, transactions-in-sql				
What capability does a database `SAVEPOINT` provide within an ongoing SQL transaction?	It sets a rollback marker allowing partial transaction rollback without aborting the entire transaction.	It pauses concurrent queries across the entire database cluster.	It commits preceding statements permanently while keeping subsequent ones open.	It automatically encrypts table data using asymmetric cryptography.	A	`SAVEPOINT name` allows issuing `ROLLBACK TO SAVEPOINT name`, undoing only work performed after that marker while keeping the transaction active.	Databases	SQL	Transactions in SQL	Intermediate	Elements	computing, databases, sql, transactions-in-sql				
Four students achieve exam scores: [100, 90, 90, 80]. What is the rank value assigned to score 80 under the window function `DENSE_RANK() OVER (ORDER BY score DESC)`?	5	2	4	3	D	**Given:** Scores: [100, 90, 90, 80] ordered DESC. **Formula:** DENSE_RANK assigns consecutive ranks without gaps when duplicate scores occur. **Calculation:** Rank 1: score 100. Rank 2: score 90 (both tied rows receive 2). Next distinct score 80 receives consecutive rank 3 (unlike RANK() which skips to 4). Thus DENSE_RANK = 3. **Answer:** 3	Databases	SQL	Window functions	Hard	Solving	computing, databases, sql, window-functions				
What is the fundamental architectural difference between an SQL window function and an SQL GROUP BY aggregation?	A window function calculates aggregates while preserving each individual row; GROUP BY collapses multiple rows into a single summary row.	A window function can only operate on primary keys; GROUP BY operates on foreign keys only.	A window function physically modifies disk storage; GROUP BY stores data in virtual views.	A window function executes before the WHERE clause; GROUP BY executes after the ORDER BY clause.	A	Window functions compute over an `OVER ()` partition without collapsing rows, maintaining the original cardinality of the query.	Databases	SQL	Window functions	Intermediate	Elements	computing, databases, sql, window-functions				
Table `Trans` has rows with `amt`: [10, 20, 30] sorted by `id`. Calculate the running total value produced at the third row by: `SUM(amt) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)`.	50	20	30	60	D	**Given:** Amounts: row 1 = 10, row 2 = 20, row 3 = 30. **Formula:** Running total at row $k$ = $\sum_{i=1}^k \text{amt}_i$. **Calculation:** Row 1: 10. Row 2: $10 + 20 = 30$. Row 3: $10 + 20 + 30 = 60$. The running total at row 3 is 60. **Answer:** 60	Databases	SQL	Window functions	Intermediate	Solving	computing, databases, sql, window-functions				
What is the default window frame applied in SQL when an `OVER (ORDER BY ...)` clause is specified without an explicit frame clause?	ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING.	ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.	RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING.	RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.	D	Under SQL standard, providing ORDER BY defaults the frame to `RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`.	Databases	SQL	Window functions	Intermediate	Elements	computing, databases, sql, window-functions				
What is the fundamental architectural difference between an SQL window function and an SQL GROUP BY aggregation?	A window function calculates aggregates while preserving each individual row; GROUP BY collapses multiple rows into a single summary row.	A window function can only operate on primary keys; GROUP BY operates on foreign keys only.	A window function physically modifies disk storage; GROUP BY stores data in virtual views.	A window function executes before the WHERE clause; GROUP BY executes after the ORDER BY clause.	A	Window functions compute over an `OVER ()` partition without collapsing rows, maintaining the original cardinality of the query.	Databases	SQL	Window functions	Intermediate	Elements	computing, databases, sql, window-functions				
What is the default window frame applied in SQL when an `OVER (ORDER BY ...)` clause is specified without an explicit frame clause?	ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING.	ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.	RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING.	RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.	D	Under SQL standard, providing ORDER BY defaults the frame to `RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`.	Databases	SQL	Window functions	Intermediate	Elements	computing, databases, sql, window-functions				
Four students achieve exam scores: [100, 90, 90, 80]. What is the rank value assigned to score 80 under the window function `DENSE_RANK() OVER (ORDER BY score DESC)`?	5	3	4	2	B	**Given:** Scores: [100, 90, 90, 80] ordered DESC. **Formula:** DENSE_RANK assigns consecutive ranks without gaps when duplicate scores occur. **Calculation:** Rank 1: score 100. Rank 2: score 90 (both tied rows receive 2). Next distinct score 80 receives consecutive rank 3 (unlike RANK() which skips to 4). Thus DENSE_RANK = 3. **Answer:** 3	Databases	SQL	Window functions	Hard	Solving	computing, databases, sql, window-functions				
Table `Trans` has rows with `amt`: [10, 20, 30] sorted by `id`. Calculate the running total value produced at the third row by: `SUM(amt) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)`.	50	60	30	20	B	**Given:** Amounts: row 1 = 10, row 2 = 20, row 3 = 30. **Formula:** Running total at row $k$ = $\sum_{i=1}^k \text{amt}_i$. **Calculation:** Row 1: 10. Row 2: $10 + 20 = 30$. Row 3: $10 + 20 + 30 = 60$. The running total at row 3 is 60. **Answer:** 60	Databases	SQL	Window functions	Hard	Solving	computing, databases, sql, window-functions				
Four students achieve exam scores: [100, 90, 90, 80]. What is the rank value assigned to score 80 under the window function `DENSE_RANK() OVER (ORDER BY score DESC)`?	5	2	3	4	C	**Given:** Scores: [100, 90, 90, 80] ordered DESC. **Formula:** DENSE_RANK assigns consecutive ranks without gaps when duplicate scores occur. **Calculation:** Rank 1: score 100. Rank 2: score 90 (both tied rows receive 2). Next distinct score 80 receives consecutive rank 3 (unlike RANK() which skips to 4). Thus DENSE_RANK = 3. **Answer:** 3	Databases	SQL	Window functions	Intermediate	Solving	computing, databases, sql, window-functions				
Table `Trans` has rows with `amt`: [10, 20, 30] sorted by `id`. Calculate the running total value produced at the third row by: `SUM(amt) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)`.	50	20	60	30	C	**Given:** Amounts: row 1 = 10, row 2 = 20, row 3 = 30. **Formula:** Running total at row $k$ = $\sum_{i=1}^k \text{amt}_i$. **Calculation:** Row 1: 10. Row 2: $10 + 20 = 30$. Row 3: $10 + 20 + 30 = 60$. The running total at row 3 is 60. **Answer:** 60	Databases	SQL	Window functions	Intermediate	Solving	computing, databases, sql, window-functions				