Computer Knowledge

Database and SQL

4,213 Questions

Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.

SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions

Database and SQL Questions

Multiple choice technology databases
  1. select count() from emp group by empno having count() >2;

  2. select empno, count() from emp having count() >2;

  3. select empno, count() from emp where count() >2;

  4. select empno, count() from emp group by empno having count() >2;

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To find employee numbers appearing more than twice, we need to: 1) Group by empno to aggregate occurrences, 2) Count occurrences with count(*), 3) Filter groups having count > 2 using HAVING clause. Option D correctly implements all three steps. Option A lacks the empno column in SELECT. Option B lacks GROUP BY. Option C incorrectly uses WHERE instead of HAVING for aggregate filtering.

Multiple choice technology databases
  1. Query

  2. Attribute

  3. Relation

  4. Record

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In relational database terminology, a row represents a single complete record of data. Columns are called attributes or fields. The entire table represents a relation. Therefore, 'Record' is the correct term for a row in database context.

Multiple choice technology databases
  1. AVG ( )

  2. SQRT ( )

  3. COUNT ( )

  4. All the Above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Single-value functions (also called scalar functions) operate on individual values and return a single value. SQRT() is a classic example - it takes one number and returns its square root. AVG() and COUNT() are aggregate functions that operate on multiple rows. Option D 'All the Above' is incorrect because it mixes scalar and aggregate functions.

Multiple choice technology
  1. to filter data during extraction

  2. to join two tables of heterogeneous source

  3. none of the above

  4. Both 1& 2

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

SQL override in Source Qualifier transformation allows you to write custom SQL queries to filter data during extraction from the source. While it can also join tables from the same homogeneous source, joining heterogeneous sources (different database types) is typically done through joiner transformations, not SQL override alone.

Multiple choice technology
  1. Import/Replace into source analyser and then to target designer.

  2. Import/Replace into target designer and then to source analyser.

  3. Both a and b.

  4. None of these.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Tables should first be imported or replaced in the Source Analyzer, and then copied to the Target Designer. This maintains proper metadata relationships and object hierarchy.

Multiple choice technology
  1. Lookup

  2. Expression

  3. Stored Procedure

  4. Transaction Control

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Transaction Control transformation is strictly an active/connected transformation - it must be connected to the data flow and cannot be used unconnected. It generates transaction control events (commit, rollback) based on conditions and changes the transaction boundary. In contrast, Lookup can be connected or unconnected, Expression is passive and connected, Stored Procedure can be connected or unconnected.

Multiple choice technology testing
  1. Return value of the API.

  2. Updates that the API does to the database tables.

  3. Exceptions that are thrown by the API.

  4. Above all

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Comprehensive API validation requires checking all aspects: the return value verifies the output is correct, database updates confirm data persistence works properly, and exception handling ensures the API responds appropriately to errors. Each validation type catches different issues - return values check business logic, database updates verify data integrity, and exception testing confirms error handling.

Multiple choice technology testing
  1. Scalar Value

  2. Row count

  3. Empty/not-empty result sets

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Database unit tests in VSTT support multiple test conditions: Scalar Value checks verify specific return values from functions or procedures, Row count validates that queries return the expected number of rows, and Empty/not-empty result set conditions confirm whether a query returned any data. Each condition type serves different validation needs - scalar values test computed results, row counts verify data volume, and result set checks confirm data presence.

Multiple choice technology databases
  1. Second

  2. Fifth

  3. Third

  4. None of above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Third Normal Form (3NF) requires that all non-key attributes are functionally dependent only on the primary key, eliminating transitive dependencies where a non-key attribute depends on another non-key attribute. 2NF only addresses partial dependencies, while 5NF deals with join dependencies.

Multiple choice technology databases
  1. AOL

  2. BOL

  3. DOL

  4. Heap

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In SQL Server, a table without a clustered index is called a heap. Data in a heap is stored without any organized order based on key values, unlike tables with clustered indexes where rows are physically sorted. The other options (AOL, BOL, DOL) are not SQL Server storage terminology.

Multiple choice technology databases
  1. Primary key constraint

  2. Check constraint

  3. Foreign key constraint

  4. Unique constraint

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Domain integrity ensures that data values fall within defined valid domains for each column. Check constraints enforce domain integrity by validating column values against specific conditions (e.g., age > 0, price BETWEEN 0 AND 1000). Primary key and unique constraints enforce entity integrity (row uniqueness), while foreign key enforces referential integrity between related tables.

Multiple choice technology databases
  1. DELETE statements only.

  2. INSERT statements only.

  3. UPDATE statements only.

  4. UPDATE, DELETE, INSERT and SELECT statements.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

SQL subqueries can be nested within all major Data Manipulation Language statements. They provide powerful query capabilities in SELECT statements for filtering and projection, and can also be used in UPDATE, DELETE, and INSERT statements to determine which rows are affected or what values are inserted.