MCQs / Computer Science / NSCT: Databases
NSCT: Databases MCQs — Computer Science (page 2) 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.
26. An attribute such as PhoneNumbers that can hold several values is: Derived Multivalued Composite key Atomic Answer: B) Multivalued
Explanation: Shown as a double ellipse. Lesson 4.1 · Databases
Discuss this question
27. Which ACID property guarantees that committed changes survive a power failure? Consistency Atomicity Isolation Durability Answer: D) Durability
Explanation: Logs make committed work permanent. Lesson 4.4 · Databases
Discuss this question
28. A query run twice in one transaction returns extra rows inserted by another transaction. This is a: Non-repeatable write Lost update Phantom read Dirty read Answer: C) Phantom read
Explanation: New rows "appear" like phantoms. Lesson 4.4 · Databases
Discuss this question
29. CREATE, ALTER and DROP belong to: DCL TCL DML DDL Answer: D) DDL
Explanation: Data Definition Language changes structure. Lesson 4.2 · Databases
Discuss this question
30. A cell containing "Math, Physics, CS" in a Subjects column violates: 3NF 1NF 2NF BCNF Answer: B) 1NF
Explanation: The value is not atomic. Lesson 4.3 · Databases
Discuss this question
31. Table Order(OrderID, ProductID, ProductName, Qty) has key (OrderID, ProductID). ProductName depends only on ProductID. The table violates: 1NF 2NF None – it is fully normalized BCNF only Answer: B) 2NF
Explanation: This is a partial dependency. Lesson 4.3 · Databases
Discuss this question
32. A transaction is: A backup file A logical unit of work that must complete fully or not at all A table A type of index Answer: B) A logical unit of work that must complete fully or not at all
Explanation: e.g. a money transfer. Lesson 4.4 · Databases
Discuss this question
33. Which WHERE clause usually prevents the use of an index on column name? WHERE name LIKE 'Ali%' WHERE name IN ('Ali', 'Sara') WHERE name = 'Ali' WHERE name LIKE '%ali' Answer: D) WHERE name LIKE '%ali'
Explanation: A leading wildcard forces a full scan. Lesson 4.5 · Databases
Discuss this question
34. A relation with a single-attribute primary key and no non-key attributes depending on each other is at least in: 3NF 2NF only 1NF only Not normalized Answer: A) 3NF
Explanation: With a single-column key, partial dependency is impossible, and no transitive dependency means 3NF. Lesson 4.3 · Databases
Discuss this question
35. Splitting a large table's rows across several servers is called: Replication Indexing Normalization Sharding (horizontal partitioning) Answer: D) Sharding (horizontal partitioning)
Explanation: Each shard holds a subset of rows. Lesson 4.5 · Databases
Discuss this question
36. Which clause filters groups after aggregation? WHERE HAVING GROUP BY ORDER BY Answer: B) HAVING
Explanation: WHERE filters rows before grouping. Lesson 4.2 · Databases
Discuss this question
37. ETL in data warehousing stands for: Evaluate, Test, Launch Export, Translate, Link Encrypt, Transfer, Log Extract, Transform, Load Answer: D) Extract, Transform, Load
Explanation: Data is cleaned and loaded into the warehouse. Lesson 4.5 · Databases
Discuss this question
38. Which query returns the second-highest salary? SELECT MAX(salary) FROM emp WHERE salary < (SELECT MAX(salary) FROM emp) SELECT MIN(salary) FROM emp SELECT salary FROM emp ORDER BY salary LIMIT 2 SELECT MAX(salary) FROM emp Answer: A) SELECT MAX(salary) FROM emp WHERE salary < (SELECT MAX(salary) FROM emp)
Explanation: The subquery removes the top salary. Lesson 4.2 · Databases
Discuss this question
39. A shared (S) lock allows: Only the DBA to read Other transactions to read but not write the item Other transactions to write No other access at all Answer: B) Other transactions to read but not write the item
Explanation: Exclusive (X) locks block both reads and writes. Lesson 4.4 · Databases
Discuss this question
40. Using the tables below, what does this query return? sql SELECT name FROM student WHERE city IN ('Karachi', 'Quetta') AND dept < 'SE'; 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 Ayesha, Zain, Ali Ayesha, Bilal Ayesha, Zain Ayesha Answer: C) Ayesha, Zain
Explanation: Running the query on the given data returns: Ayesha, Zain. Lesson 4.2 · Databases
Discuss this question
41. Using the tables below, what does this query return? sql SELECT MAX(marks) - MIN(marks) FROM enrol; 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) 35 36 37 38 Answer: B) 36
Explanation: Running the query on the given data returns: 36. Lesson 4.2 · Databases
Discuss this question
42. A CROSS JOIN of a table with 4 rows and a table with 5 rows returns: 5 rows 4 rows 20 rows 9 rows Answer: C) 20 rows
Explanation: Every combination: 4 × 5. Lesson 4.2 · Databases
Discuss this question
43. The strongest SQL isolation level is: Read Committed Read Uncommitted Serializable Repeatable Read Answer: C) Serializable
Explanation: It prevents dirty, non-repeatable and phantom reads. Lesson 4.4 · Databases
Discuss this question
44. UNION differs from UNION ALL because UNION: Sorts by primary key only Removes duplicate rows Keeps duplicates Works only on one table Answer: B) Removes duplicate rows
Explanation: UNION ALL is faster as it skips duplicate removal. Lesson 4.2 · Databases
Discuss this question
45. The number of attributes (columns) in a relation is its: Arity of rows Cardinality Domain Degree Answer: D) Degree
Explanation: Cardinality is the number of tuples. Lesson 4.1 · Databases
Discuss this question
46. Using the tables below, what does this query return? sql SELECT COUNT(DISTINCT city) 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 3 6 5 4 Answer: D) 4
Explanation: Running the query on the given data returns: 4. Lesson 4.2 · Databases
Discuss this question
47. The logical order of execution of a SELECT query starts with: WHERE SELECT FROM ORDER BY Answer: C) FROM
Explanation: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY. Lesson 4.2 · Databases
Discuss this question
48. Using the tables below, what does this query return? sql SELECT name FROM student WHERE cgpa IS NULL; 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 Hina NULL (no rows) Zain Answer: D) Zain
Explanation: Running the query on the given data returns: Zain. Lesson 4.2 · Databases
Discuss this question
49. The main purpose of normalization is to: Encrypt data Increase redundancy Reduce redundancy and update anomalies Speed up network traffic Answer: C) Reduce redundancy and update anomalies
Explanation: It organises tables logically. Lesson 4.3 · Databases
Discuss this question
50. The functional dependency RollNo → Name means: RollNo is a foreign key Each RollNo determines exactly one Name Names are unique Each Name determines one RollNo Answer: B) Each RollNo determines exactly one Name
Explanation: Same roll number always gives the same name. Lesson 4.3 · Databases
Discuss this question
Previous Page 2 of 5 Next
Practise NSCT: Databases MCQs
More Computer Science chapters