0
0
DBMS Theoryknowledge~20 mins

Integrity constraints in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Integrity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📋 Factual
intermediate
2:00remaining
Understanding Primary Key Constraints

Which of the following statements about primary key constraints in a database is correct?

AA primary key can contain NULL values as long as it uniquely identifies rows.
BA primary key allows duplicate values but no NULL values.
CA primary key uniquely identifies each row and cannot contain NULL values.
DA primary key is optional and used only for indexing purposes.
Attempts:
2 left
💡 Hint

Think about what makes each row in a table unique and how NULL values affect uniqueness.

🧠 Conceptual
intermediate
2:00remaining
Role of Foreign Key Constraints

What is the main purpose of a foreign key constraint in a relational database?

ATo prevent any NULL values in a column.
BTo ensure that values in one table match values in another table, maintaining referential integrity.
CTo enforce that all values in a column are unique within the same table.
DTo automatically generate unique values for a column.
Attempts:
2 left
💡 Hint

Consider how tables relate to each other and how data consistency is maintained across tables.

🔍 Analysis
advanced
2:00remaining
Effect of NOT NULL Constraint on Data Entry

Consider a table with a column defined as NOT NULL. What will happen if you try to insert a row without specifying a value for this column?

AThe database will reject the insertion and raise an error.
BThe row will be inserted with a default NULL value in that column.
CThe database will automatically assign a random value to the column.
DThe insertion will succeed but the column will be left empty.
Attempts:
2 left
💡 Hint

Think about what NOT NULL means for a column's data.

Comparison
advanced
2:00remaining
Difference Between UNIQUE and PRIMARY KEY Constraints

Which of the following best describes a key difference between UNIQUE and PRIMARY KEY constraints?

AA UNIQUE constraint allows multiple NULL values, but a PRIMARY KEY does not allow any NULL values.
BA PRIMARY KEY allows duplicate values, but a UNIQUE constraint does not.
CBoth constraints allow NULL values but differ in indexing methods.
DA UNIQUE constraint is mandatory for every table, but a PRIMARY KEY is optional.
Attempts:
2 left
💡 Hint

Consider how NULL values are treated differently by these constraints.

Reasoning
expert
2:00remaining
Impact of CHECK Constraints on Data Validity

A table has a CHECK constraint defined as CHECK (age >= 18). What will happen if an attempt is made to insert a row with age = 16?

AThe row will be inserted because CHECK constraints are only warnings.
BThe row will be inserted but the age value will be ignored.
CThe database will automatically change the age to 18 before inserting.
DThe insertion will fail with a constraint violation error.
Attempts:
2 left
💡 Hint

Think about what a CHECK constraint enforces on data values.