Which column property would you use to require that a monetary amount in one column be less than another monetary amount in the same row (for example, discount_amount < total_amount)?
-
ANull status
-
BData type
-
CDefault value
-
DData constraints
Answer
Correct Answer: Data constraints
Explanation
Introduction / Context:Relational databases can enforce business rules at the schema level. A common rule compares values across columns within the same row (for example, a discount cannot exceed the total).
Given Data / Assumptions:
- The comparison is row-scoped (same row).
- We need a declarative way to enforce an inequality between two columns.
Concept / Approach:Data constraints, typically a CHECK constraint, let you express rules such as discount_amount < total_amount. Data type defines format, null status controls presence, and default value provides a fallback value—none of those compare two columns.
Step-by-Step Solution:
Identify rule: one column must be less than another.Use a CHECK constraint to express the predicate (for example, CHECK (discount_amount <= total_amount)).Therefore, choose “Data constraints.”Verification / Alternative check:DBMS DDL shows CHECK constraints evaluating boolean expressions per row during INSERT/UPDATE.
Why Other Options Are Wrong:Null status/Data type/Default value: None can enforce cross-column comparison by themselves.
Common Pitfalls:Forgetting to consider NULL semantics (for example, when either column is NULL, the CHECK may evaluate to unknown and pass/fail depending on DBMS). Require NOT NULL if appropriate.
Final Answer:Data constraints