Challenge - 5 Problems
Database Integrity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What is the main purpose of database testing in ensuring data integrity?
Choose the best explanation for why database testing is important for data integrity.
Attempts:
2 left
💡 Hint
Think about what data integrity means in terms of data correctness and accuracy.
✗ Incorrect
Database testing focuses on verifying that data is stored, retrieved, and updated correctly, which keeps data accurate and consistent.
🧠 Conceptual
intermediate2:00remaining
Which database testing activity helps prevent data corruption?
Select the database testing activity that directly helps maintain data integrity by preventing corruption.
Attempts:
2 left
💡 Hint
Data constraints control how data relates and what values are allowed.
✗ Incorrect
Testing constraints ensures that invalid or duplicate data cannot enter the database, preventing corruption.
❓ Predict Output
advanced2:00remaining
What is the output of this SQL query after inserting duplicate primary key?
Given a table with a primary key, what happens when you try to insert a duplicate key?
Testing Fundamentals
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50)); INSERT INTO users VALUES (1, 'Alice'); INSERT INTO users VALUES (1, 'Bob');
Attempts:
2 left
💡 Hint
Primary keys must be unique for each row.
✗ Incorrect
Inserting a duplicate primary key violates the uniqueness rule, causing an error and preventing data corruption.
❓ assertion
advanced2:00remaining
Which assertion best verifies data integrity after a database update?
Choose the assertion that confirms data was updated correctly without corruption.
Testing Fundamentals
UPDATE accounts SET balance = balance - 100 WHERE account_id = 123;
Attempts:
2 left
💡 Hint
Check if the data changed as expected after the update.
✗ Incorrect
Verifying the updated balance matches the expected value confirms data integrity after the operation.
🔧 Debug
expert3:00remaining
Why does this test fail to ensure data integrity?
Identify the reason this database test does not properly verify data integrity.
Testing Fundamentals
def test_insert_user(db): db.execute("INSERT INTO users (id, name) VALUES (1, 'Alice')") result = db.query("SELECT * FROM users WHERE id = 1") assert result == [(1, 'Alice')]
Attempts:
2 left
💡 Hint
Check the data types and structure returned by the query versus the assertion.
✗ Incorrect
The query returns a tuple with id and name, but the assertion expects a list with only the name string, causing failure.