AD0-E716 · Question #28
An Adobe Commerce developer is trying to create a custom table using declarative schema, but is unable to do so. What are two errors in the snippet above? (Choose two.)
The correct answers are A and C. Why A is correct: In Adobe Commerce declarative schema (db_schema.xml), a column with identity="true" is an auto-increment column and must be defined as a primary key with a corresponding <constraint> element of type PRIMARY. Without that…
Question
An Adobe Commerce developer is trying to create a custom table using declarative schema, but is unable to do so. What are two errors in the snippet above? (Choose two.)
Exhibit
Options
- AColumn (roll_no) does not have index. It is needed since attribute identity is set to true.
- BColumn (entity_id) does not have index. It is needed since attribute identity is set to false.
- CColumn (student_name) does not have attribute length.
- Dnull is not a valid value for column (roll_no).
Explanation
The correct answers are A and C.
Why A is correct: In Adobe Commerce declarative schema (db_schema.xml), a column with identity="true" is an auto-increment column and must be defined as a primary key with a corresponding <constraint> element of type PRIMARY. Without that index/constraint, the schema processor cannot validate or apply the table definition, causing a setup error.
Why C is correct: String-type columns (e.g., varchar) in declarative schema require an explicit length attribute. Omitting it is a syntax/validation error because Magento cannot determine the column's storage size - there is no default fallback for string length in db_schema.xml.
Why B is wrong: identity="false" simply means the column is not auto-increment. That condition alone does not mandate an index; indexes are only required for specific use cases like primary keys or foreign key targets.
Why D is wrong: null (i.e., nullable="true") is a perfectly valid attribute value in declarative schema. Whether a column accepts NULL values is controlled by the nullable attribute and is not inherently an error.
Memory tip: Think "Auto-increment = needs a primary key" (A) and "String = needs a size" (C) - both are cases where the schema engine needs explicit information it cannot guess on its own.
Topics
Community Discussion
No community discussion yet for this question.
