Computer Knowledge
Database and SQL
3,929 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
A
Correct answer
Explanation
A JOIN clause in SQL is used to combine rows from two or more tables based on a related column between them, allowing you to query associated data together.
-
Unique Value
-
Integer Data Type
-
Not Null
-
Foreign
A,C
Correct answer
Explanation
A primary key uniquely identifies each record in a database table. Therefore, it must contain unique values and cannot contain NULL values. It does not have to be an integer, nor does it have to be a foreign key.
-
Connection Key
-
Primary Key
-
Candidate Key
-
Foreign Key
D
Correct answer
Explanation
A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key or a unique key of another table.
B
Correct answer
Explanation
INSERT, UPDATE, and DELETE are part of Data Manipulation Language (DML) because they are used to manage and manipulate data within existing schema objects. DDL is used for defining schemas, DQL for querying, and TCL for transaction control.
-
Every table must have a primary key
-
Foreign keys must always reference a valid unique key
-
Joins should only be used with foreign and primary keys
-
Columns should be atomic
B
Correct answer
Explanation
Referential integrity ensures that relationships between tables remain consistent. It requires that any foreign key field in a table must point to a valid, existing primary key or unique key in the referenced table, preventing orphaned records.
-
May throw NullPointerExceptions
-
Have undefined behavior in logical expressions
-
Represent the lack of a value for a column
-
Are only valid in columns with the NULLABLE constraint
C
Correct answer
Explanation
In SQL, NULL is a special marker used to indicate that a data value does not exist in the database. It represents missing, unknown, or inapplicable data, rather than a zero or an empty string.
-
Unique in the table
-
Uniquely reference a primary key
-
Unique in the row
-
Unique in the column
D
Correct answer
Explanation
The UNIQUE constraint ensures that all values in a specific column are different across all rows in the table. While this makes the values unique within that column across the table, the most precise description is that the values must be unique within that column.
-
composite key
-
double-primary key
-
consisting key
-
foreign key
A
Correct answer
Explanation
A composite key is a combination of two or more columns in a table that can be used to uniquely identify each row in the table. When multiple columns are combined to form a primary key, it is specifically referred to as a composite primary key.
-
Database
-
cookie
-
filed
-
Dynamic
D
Correct answer
Explanation
In computer science and general terminology, "dynamic" refers to systems or processes that are constantly changing, active, or progressing. A database is a structured set of data, a cookie is a small text file stored by a browser, and "filed" is a past tense verb or typo for field.
-
structured query language
-
structured question language
-
strong question language
A
Correct answer
Explanation
SQL stands for Structured Query Language, which is the standard programming language used to manage and manipulate relational databases. It allows users to perform tasks such as querying, updating, and inserting data. The other options use incorrect words like 'question' instead of 'query'.
Which of the following is a common technique used to mitigate SQL injection vulnerabilities?
-
Input validation
-
Use of prepared statements
-
Escaping special characters
-
All of the above
D
Correct answer
Explanation
Input validation, use of prepared statements, and escaping special characters are all effective techniques to prevent SQL injection attacks.
What is an elementary row operation?
-
Adding a multiple of one row to another row.
-
Multiplying a row by a nonzero constant.
-
Swapping two rows.
-
All of the above.
D
Correct answer
Explanation
Elementary row operations are operations that can be performed on a matrix without changing the solution set of the corresponding system of linear equations. The three elementary row operations are adding a multiple of one row to another row, multiplying a row by a nonzero constant, and swapping two rows.
Which of the following is NOT a common application of DSSs in the legal context?
-
Litigation risk assessment
-
Settlement negotiation
-
Legal research and analysis
-
Tax planning and preparation
D
Correct answer
Explanation
Tax planning and preparation is typically not an area where DSSs are commonly applied in the legal field.
What is the best way to protect against SQL injection attacks?
-
Use parameterized queries
-
Use input validation
-
Keep your software up to date
-
All of the above
D
Correct answer
Explanation
The best way to protect against SQL injection attacks is to use parameterized queries, use input validation, and keep your software up to date.
Which SQL statement is used to retrieve data from a database?
-
SELECT
-
INSERT
-
UPDATE
-
DELETE
A
Correct answer
Explanation
The SELECT statement is used to retrieve data from a database. It allows you to specify the columns and rows to be retrieved, as well as filter and sort the results.