JSON Data Type & Functions — Concept Check
Questions on JSON Data Type & Functions. MySQL 5.7+ stores JSON as a binary type with path expressions (->>, JSON_EXTRACT, JSON_SET); generated virtual columns on JSON paths can be indexed for efficient JSON queries.
Questions in this quiz
8 questions on JSON Data Type & Functions — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer needs to update the 'price' field in a JSON column without rewriting the entire document. Which function should they use?
- AJSON_SET
- BJSON_REMOVE
- CJSON_REPLACE
- DJSON_EXTRACT
2.You want to index the 'color' attribute in a JSON column for faster queries. What is the correct approach?
- AUse JSON_EXTRACT to index
- BCreate a virtual generated column and index it
- CDirectly index the JSON column
- DIndex using JSON_SET
3.A query using `attributes->>'$.color' = 'red'` is slow. How can indexing improve it?
- AApply JSON_REPLACE to optimize
- BIndex the JSON column directly
- CCreate a virtual column for 'color' and index it
- DUse JSON_MERGE_PATCH for indexing
4.A table has a JSON column with an array. How can you efficiently check if 'sale' is in the array?
- AApply JSON_REMOVE first
- BUse MEMBER OF and a multi-value index
- CUse JSON_SET to add 'sale'
- DDirectly query with JSON_EXTRACT
5.A developer mistakenly believes JSON columns can be indexed directly. What is the correct method?
- AIndex using JSON_SET
- BApply JSON_REMOVE for indexing
- CUse virtual generated columns for indexing
- DDirectly index the JSON column
6.When inserting a JSON document, what ensures its structure is valid?
- AJSON_SET ensures valid structure
- BJSON_EXTRACT checks structure
- CMySQL validates JSON structure on insert
- DJSON_REMOVE validates structure
7.A developer uses JSON_TABLE to convert JSON arrays to relational rows. What is a common use case?
- ARemoving keys from JSON
- BNormalizing semi-structured data inline
- CIndexing JSON arrays directly
- DUpdating JSON paths efficiently
8.Which operator returns an unquoted string from a JSON path?
- A->>
- BJSON_EXTRACT
- C->
- DJSON_SET