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
What is the term for a unique identifier assigned to each row in a table?
-
Primary Key
-
Foreign Key
-
Candidate Key
-
Alternate Key
A
Correct answer
Explanation
A primary key is a unique identifier assigned to each row in a table. It ensures that each row can be uniquely identified and serves as the basis for establishing relationships between tables.
What is the term for a logical connection between two tables based on a common column or attribute?
-
Primary Key
-
Foreign Key
-
Candidate Key
-
Alternate Key
B
Correct answer
Explanation
A foreign key is a logical connection between two tables based on a common column or attribute. It ensures that the data in the child table is related to the data in the parent table, maintaining referential integrity.
Which normalization form ensures that each attribute in a relation is dependent on the primary key?
-
First Normal Form (1NF)
-
Second Normal Form (2NF)
-
Third Normal Form (3NF)
-
Boyce-Codd Normal Form (BCNF)
B
Correct answer
Explanation
2NF requires that all non-key attributes be fully dependent on the primary key, eliminating partial dependencies.
How do you search a legal research database?
-
By using keywords
-
By using Boolean operators
-
By using both keywords and Boolean operators
-
None of the above
C
Correct answer
Explanation
You can search a legal research database by using keywords, Boolean operators, or both.
What does the OR operator do?
-
It connects two search terms and broadens the results
-
It connects two search terms and narrows the results
-
It excludes one search term from the results
-
None of the above
A
Correct answer
Explanation
The OR operator connects two search terms and broadens the results.
What is the purpose of a foreign key in a database table?
-
To uniquely identify each row in the table
-
To store the most important data in the table
-
To create a relationship between two tables
-
To index the data in the table
C
Correct answer
Explanation
A foreign key is a column or set of columns in a database table that references a primary key in another table.
What is the purpose of a trigger in a database?
-
To store data
-
To process data
-
To retrieve data
-
To update data
D
Correct answer
Explanation
A trigger is a stored procedure that is automatically executed when a specific event occurs in a database.
What is the purpose of a transaction in a database?
-
To store data
-
To process data
-
To retrieve data
-
To update data
D
Correct answer
Explanation
A transaction is a set of operations that are executed as a single unit. Transactions are used to ensure that data is updated consistently.
Which of the following is NOT a best practice for preventing SQL injection attacks?
-
Use parameterized queries
-
Escape user input before using it in SQL queries
-
Use a WAF to block malicious traffic
-
Use a strong password for the database user
D
Correct answer
Explanation
While using a strong password for the database user is a good security practice, it is not a specific measure for preventing SQL injection attacks.
What is the key difference between 1NF and 2NF?
-
1NF eliminates repeating groups, while 2NF eliminates partial dependencies.
-
1NF ensures atomic values in columns, while 2NF eliminates transitive dependencies.
-
1NF removes duplicate rows, while 2NF removes duplicate columns.
-
1NF establishes primary keys, while 2NF establishes foreign keys.
A
Correct answer
Explanation
In 1NF, repeating groups are eliminated by creating separate tables for each group. In 2NF, partial dependencies are eliminated by ensuring that each non-key column is fully dependent on the primary key.
Which normal form ensures that all non-key columns are directly dependent on the primary key?
-
First Normal Form (1NF)
-
Second Normal Form (2NF)
-
Third Normal Form (3NF)
-
Boyce-Codd Normal Form (BCNF)
B
Correct answer
Explanation
Second Normal Form (2NF) ensures that all non-key columns are fully dependent on the primary key, meaning that they cannot be derived from any proper subset of the primary key.
Which normal form ensures that all non-key columns are directly dependent on the primary key and that there are no transitive dependencies?
-
First Normal Form (1NF)
-
Second Normal Form (2NF)
-
Third Normal Form (3NF)
-
Boyce-Codd Normal Form (BCNF)
D
Correct answer
Explanation
Boyce-Codd Normal Form (BCNF) ensures that all non-key columns are directly dependent on the primary key and that there are no transitive dependencies. It is the highest level of normalization among the common normal forms.
Which normalization form ensures that each attribute in a table is dependent on the primary key and not on any other attribute?
-
First Normal Form (1NF)
-
Second Normal Form (2NF)
-
Third Normal Form (3NF)
-
Boyce-Codd Normal Form (BCNF)
C
Correct answer
Explanation
Third Normal Form (3NF) is the normalization form that ensures that each attribute in a table is dependent on the primary key and not on any other attribute. This eliminates transitive dependencies and ensures data integrity and consistency.