nerdexam
Oracle

1Z0-909 · Question #1

You must enforce data integrity for data Inserted in a JSON column. Which statement successfully creates a constraint in a 3SON column?

The correct answer is C. CREATE TABLE fshop (id INT NOT NULL AUTOINCREMENT, product JSON, PRIMARY KEY. Option C creates a valid table structure using a PRIMARY KEY constraint - a NOT NULL AUTO_INCREMENT integer as the primary key alongside the JSON column - which is a reliably enforced data integrity mechanism in all MySQL versions. Option A's CHECK (JSON_VALID(product))…

JSON

Question

You must enforce data integrity for data Inserted in a JSON column. Which statement successfully creates a constraint in a 3SON column?

Options

  • ACREATE TABLE fshop (product JSON CHECK (JSON_VALID(product) ) ) ;
  • BCREATE TABLE fshop ( product JSON, f INT' GENERATED ALWAYS AS (product->"S - id") ) ;
  • CCREATE TABLE fshop (id INT NOT NULL AUTOINCREMENT, product JSON, PRIMARY KEY
  • DCREATE TABLE fshop (id INT NOT NULL AUTO_ INCREMENT, product JSON, CHECK (id>0) )

How the community answered

(32 responses)
  • A
    9% (3)
  • B
    3% (1)
  • C
    75% (24)
  • D
    13% (4)

Explanation

Option C creates a valid table structure using a PRIMARY KEY constraint - a NOT NULL AUTO_INCREMENT integer as the primary key alongside the JSON column - which is a reliably enforced data integrity mechanism in all MySQL versions. Option A's CHECK (JSON_VALID(product)) approach is syntactically plausible in MySQL 8.0.16+, but in earlier MySQL versions CHECK constraints were silently parsed and ignored rather than enforced, making it unreliable as a guarantee. Option B uses GENERATED ALWAYS AS with a JSON path expression, which creates a virtual/generated column derived from JSON data - useful for indexing, but not a constraint that validates inserted values. Option D applies CHECK (id > 0) to the integer column, not the JSON column, so it does nothing to ensure the integrity of JSON data.

Memory tip: Associate "data integrity" with constraints that are always enforced - PRIMARY KEY, NOT NULL, UNIQUE, and FOREIGN KEY are the four pillars. CHECK constraints on JSON columns are a modern MySQL feature; if an exam question doesn't specify MySQL 8.0.16+, treat them as unreliable.

Topics

#JSON constraints#CHECK constraints#data integrity#constraint syntax

Community Discussion

No community discussion yet for this question.

Full 1Z0-909 Practice