MCQs / Computer Science / NSCT: Databases

NSCT: Databases MCQs — Computer Science (page 5)

112 multiple-choice questions on NSCT: Databases from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.

101. INSERT, UPDATE and DELETE belong to:

  1. TCL
  2. DCL
  3. DML
  4. DDL

Answer: C) DML

Explanation: Data Manipulation Language changes rows. Lesson 4.2 · Databases

Discuss this question

102. How many clustered indexes can a table have?

  1. Unlimited
  2. None
  3. Two
  4. One

Answer: D) One

Explanation: Rows can be physically ordered only one way. Lesson 4.5 · Databases

Discuss this question

103. Using the tables below, what does this query return? sql SELECT name FROM student WHERE id IN (SELECT sid FROM enrol WHERE code = 'CS201') ORDER BY name; student id name dept cgpa city --------------- 1 Ali CS 3.4 Lahore 2 Sara SE 3.8 Karachi 3 Usman CS 2.9 Lahore 4 Hina AI 3.6 Islamabad 5 Bilal SE 3.1 Lahore 6 Ayesha CS 3.9 Karachi 7 Zain AI NULL Quetta enrol (sid, code, marks): (1, CS101, 78), (1, CS201, 65), (2, CS201, 88), (3, CS101, 55), (4, AI401, 91), (6, CS201, 72), (6, CS301, 80), (5, CS101, 60) course (code, title, credits): (CS101, Programming, 4), (CS201, Databases, 3), (CS301, Networks, 3), (AI401, Machine Learning, 3)

  1. Ali, Ayesha, Sara, Usman
  2. Ali, Ayesha
  3. Ali, Ayesha, Sara
  4. Ali, Ayesha, Zain

Answer: C) Ali, Ayesha, Sara

Explanation: Running the query on the given data returns: Ali, Ayesha, Sara. Lesson 4.2 · Databases

Discuss this question

104. Two clerks read a balance of Rs. 1,000; one adds 500 and the other subtracts 200; the final value is 800. This problem is a:

  1. Phantom read
  2. Deadlock
  3. Lost update
  4. Dirty read

Answer: C) Lost update

Explanation: One update overwrote the other. Lesson 4.4 · Databases

Discuss this question

105. A social network that stores friend-of-friend relationships is best suited to a:

  1. Graph database
  2. Column store
  3. Key-value store
  4. Flat file

Answer: A) Graph database

Explanation: Graph databases traverse relationships efficiently. Lesson 4.5 · Databases

Discuss this question

106. ROLLBACK in SQL:

  1. Creates a backup
  2. Undoes the changes of the current transaction
  3. Deletes the table
  4. Saves changes permanently

Answer: B) Undoes the changes of the current transaction

Explanation: COMMIT makes them permanent. Lesson 4.4 · Databases

Discuss this question

107. Using the tables below, what does this query return? sql SELECT name FROM student ORDER BY name LIMIT 2; student id name dept cgpa city --------------- 1 Ali CS 3.4 Lahore 2 Sara SE 3.8 Karachi 3 Usman CS 2.9 Lahore 4 Hina AI 3.6 Islamabad 5 Bilal SE 3.1 Lahore 6 Ayesha CS 3.9 Karachi 7 Zain AI NULL Quetta

  1. Ali
  2. Ali, Ayesha, Sara
  3. Ali, Zain
  4. Ali, Ayesha

Answer: D) Ali, Ayesha

Explanation: Running the query on the given data returns: Ali, Ayesha. Lesson 4.2 · Databases

Discuss this question

108. Which of the following is a DBMS?

  1. PostgreSQL
  2. Linux
  3. Python
  4. HTML

Answer: A) PostgreSQL

Explanation: PostgreSQL is a relational database management system. Lesson 4.1 · Databases

Discuss this question

109. In a star schema, the central table holding measures (sales amount, quantity) is the:

  1. Index table
  2. Fact table
  3. Dimension table
  4. Lookup table

Answer: B) Fact table

Explanation: Dimension tables (date, product) surround it. Lesson 4.5 · Databases

Discuss this question

110. Which removes all rows of a table but keeps its structure, usually without row-by-row logging?

  1. TRUNCATE
  2. DELETE without WHERE only
  3. ALTER
  4. DROP

Answer: A) TRUNCATE

Explanation: DROP removes the table itself. Lesson 4.2 · Databases

Discuss this question

111. Using the tables below, what does this query return? sql SELECT COUNT(cgpa) FROM student; student id name dept cgpa city --------------- 1 Ali CS 3.4 Lahore 2 Sara SE 3.8 Karachi 3 Usman CS 2.9 Lahore 4 Hina AI 3.6 Islamabad 5 Bilal SE 3.1 Lahore 6 Ayesha CS 3.9 Karachi 7 Zain AI NULL Quetta

  1. 8
  2. 6
  3. 7
  4. 5

Answer: B) 6

Explanation: Running the query on the given data returns: 6. Lesson 4.2 · Databases

Discuss this question

112. Using the tables below, what does this query return? sql SELECT s.name FROM student s JOIN enrol e ON s.id = e.sid WHERE e.marks 80; student id name dept cgpa city --------------- 1 Ali CS 3.4 Lahore 2 Sara SE 3.8 Karachi 3 Usman CS 2.9 Lahore 4 Hina AI 3.6 Islamabad 5 Bilal SE 3.1 Lahore 6 Ayesha CS 3.9 Karachi 7 Zain AI NULL Quetta enrol (sid, code, marks): (1, CS101, 78), (1, CS201, 65), (2, CS201, 88), (3, CS101, 55), (4, AI401, 91), (6, CS201, 72), (6, CS301, 80), (5, CS101, 60) course (code, title, credits): (CS101, Programming, 4), (CS201, Databases, 3), (CS301, Networks, 3), (AI401, Machine Learning, 3)

  1. Sara
  2. Sara, Hina, Ali
  3. Sara, Zain
  4. Sara, Hina

Answer: D) Sara, Hina

Explanation: Running the query on the given data returns: Sara, Hina. Lesson 4.2 · Databases

Discuss this question

Previous Page 5 of 5

Practise NSCT: Databases MCQs

More Computer Science chapters