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
  1. execute query

  2. update data

  3. insert data

  4. Both (2) and (3)

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

execSQL() in SQLiteDatabase is a general-purpose method for executing single SQL statements that don't return rows - primarily for queries (SELECT). For insert/update operations, Android provides dedicated methods like insert(), update(), delete() which are safer and more convenient.

Multiple choice
  1. An array of properties of instances from the content provider

  2. A constraint statement

  3. An optional set of parameters to bind into the constraint clause

  4. An optional sort statement

  5. The identifier for a layout

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

The managedQuery() method does not have any parameter like the layout identifier.

Multiple choice
  1. public void onUpgrade(SQLiteDatabase db) { db.execSQL(DROP TABLE IF EXISTS + TABLE_CONTACTS); onCreate(db); }

  2. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(DROP TABLE IF EXISTS + TABLE_CONTACTS); onCreate(db); }

  3. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(DROP TABLE IF EXISTS + TABLE_CONTACTS); onCreate(db); db.insert(); }

  4. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(DROP TABLE IF EXISTS + TABLE_CONTACTS); onCreate(db); db.close(); }

  5. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(DROP TABLE IF EXISTS + TABLE_CONTACTS); onCreate(db); db.delete(); }

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

onUpgrade() method is called when there is a database version mismatch.

Multiple choice
  1. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \times r_2 \times \dots \times r_m\right)$
  2. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \bowtie r_2 \bowtie \dots \bowtie r_m \right)$
  3. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \cup r_2 \cup \dots \cup r_m \right)$
  4. $\Pi_{a_1, a_2, … a_n} \sigma_p \left(r_1 \cap r_2 \cap \dots \cap r_m \right)$
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Multiple choice
  1. Names of students who have got an A grade in all the courses taught by Korth.

  2. Names of students who have got an A grade in all the courses.

  3. Names of students who have got an A grade in at least one of the courses taught by Korth.

  4. None of the above

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

Names are unique since they are selected distinct, so one person will be selected only once, even when he has got grade A in any number of courses taught by Korth. So, if a name is appearing it is not necessary that he scored grade A in all the courses, but scored grade A in at least one course.

Multiple choice
  1. in second normal form but not in third normal form

  2. in third normal form but not in BCNF

  3. in BCNF

  4. None of the above

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

Multiple choice
  1. 2 and 5

  2. 1 and 3

  3. 1 and 4

  4. 3 and 5

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

Multiple choice
  1. All queries return identical row sets for any database.

  2. Query2 and Query4 return identical row sets for all databases but there exist databases for which Query1 and Query2 return different row sets.

  3. There exist databases for which Query3 returns strictly fewer rows than Query 2.

  4. There exist databases for which Query4 will encounter an integrity violation at runtime.

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

Multiple choice
  1. Plan 1 and Plan 2 will not output identical row sets for all databases

  2. A course may be listed more than once in the output of Plan 1 for some databases

  3. For x = 5000, Plan 1 executes faster than Plan 2 for all databases

  4. For x = 9000, Plan I executes slower than Plan 2 for all databases.

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

Multiple choice
  1. Q1 is the correct query.

  2. Q2 is the correct query.

  3. Both Q1 and Q2 produce the same answer.

  4. Neither Q1 nor Q2 is the correct query.

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

Multiple choice
  1. Simple query wizard

  2. Make table query

  3. Cross table query

  4. Append query

  5. None of these

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

A Make-Table query creates a new table from the results of a select query. It is used to archive data, create backups, or export data in a specific format. The other query types serve different purposes - Simple Query Wizard builds basic queries, CrossTab query creates summary tables, and Append query adds records to existing tables.

Multiple choice
  1. 3

  2. 5

  3. 6

  4. 7

  5. None of these

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

Queries in MS Access can be opened in three different views: Design View (for visually designing the query), Datasheet View (for viewing query results in a table format), and SQL View (for viewing and editing the SQL statement). These three views provide different ways to interact with the query object.

Multiple choice
  1. Tools

  2. Insert

  3. Format

  4. Table

  5. None of these

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

In MS Access, the Tools menu contains the Relationships command for defining relationships between tables. This is where you go to establish referential integrity, define one-to-many or one-to-one relationships, and enforce cascading updates and deletes between related tables.

Multiple choice
  1. 4

  2. 5

  3. 6

  4. 7

  5. None of these

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

The MS Access Query menu typically shows 4 main query categories: Select Query, Make-Table Query, Update Query, and Append Query. Some versions may show different categorizations, but 4 is the standard count in the basic Query menu.