Questions
12 of 15
1What are the main categories of data types available in MySQL?
2What is the difference between CHAR and VARCHAR data types?
3Which data type would you use to store dates and times in MySQL?
4What is the difference between INT, FLOAT, and DECIMAL data types?
5What is the use of the TEXT and BLOB data types, and how are they different from VARCHAR?
6How does MySQL handle precision and scale in DECIMAL(M, D) columns internally, and how do these differ from FLOAT and DOUBLE in terms of storage and accuracy?
7When storing time zone–aware data, what are the differences in behavior and use cases between DATETIME, TIMESTAMP, and CONVERT_TZ() in MySQL?
8If you define a VARCHAR(255) column with utf8mb4 encoding, how does MySQL calculate the maximum possible storage size for that column, and how does it differ from CHAR(255)?
9What are the advantages and limitations of using ENUM and SET data types in terms of performance, flexibility, and schema evolution?
10Explain how MySQL internally stores and sorts values of type BLOB and TEXT. What happens when you try to index a TEXT column?
11How do signed and unsigned integer types affect query results, index usage, and storage size? Can you demonstrate an example where overflow behavior differs?
12In what scenarios would using a JSON column be preferable to a normalized table structure, and what are the internal storage and indexing implications of JSON in MySQL 8.0?
13How does MySQL’s BIT(M) type differ from BOOLEAN, TINYINT(1), and binary string types (BINARY, VARBINARY) in terms of storage, representation, and retrieval?
14If you define a composite index on multiple columns of different data types (e.g., INT, VARCHAR, and DATE), how do the internal data type differences influence sorting, comparisons, and index efficiency?
15What are the practical implications of using CHAR vs VARCHAR for columns in InnoDB tables with varying row lengths and frequent updates? How does this choice affect row fragmentation and performance?
12 / 15

In what scenarios would using a JSON column be preferable to a normalized table structure, and what are the internal storage and indexing implications of JSON in MySQL 8.0?

Using JSON Columns in MySQL 8.0: When to Use and How They Are Stored/Indexed

MySQL 8.0 supports a native JSON data type that is validated and stored in a binary optimized format. It is useful in cases where schema flexibility is required or when semi-structured data needs to be stored without rigid normalization.

When JSON Is Preferable Over Normalized Tables
  1. 1

    When storing semi-structured or flexible data where fields vary between rows (e.g., dynamic attributes, settings, metadata).

  2. 2

    When application-layer objects map directly to JSON, reducing transformation overhead.

  3. 3

    When you need rapid schema evolution without altering table structures.

  4. 4

    When storing large, nested objects that would otherwise require multiple join-heavy relational tables.

  5. 5

    When performance favors fewer joins over strict normalization, especially in read-heavy workloads.

When You Should Not Use JSON
  1. 1

    When strong relational integrity, foreign keys, or normalization are required.

  2. 2

    When you frequently filter or aggregate on deeply nested fields (relational structures perform better).

  3. 3

    When large JSON fields lead to unnecessary data transfer and slower updates.

Internal Storage Behavior of JSON in MySQL 8.0
  1. 1

    JSON is stored in a binary format (not plain text) optimized for lookup.

  2. 2

    The structure includes metadata such as element types and offsets for fast access.

  3. 3

    MySQL validates JSON on insert/update — invalid JSON is rejected.

  4. 4

    Large JSON values may be stored off-page by InnoDB, similar to TEXT/BLOB.

  5. 5

    Binary storage allows MySQL to parse only required portions instead of scanning entire JSON strings.

Indexing Behavior in JSON Columns
  1. 1

    MySQL cannot directly index an entire JSON document.

  2. 2

    Instead, you index generated (virtual or stored) columns extracted from JSON paths.

  3. 3

    These generated columns can be indexed normally (BTREE).

  4. 4

    MySQL 8.0 also supports functional indexes, allowing indexing of expressions like JSON_EXTRACT(data, '$.user.id').

  5. 5

    Only the generated/indexed part is searchable using the index; the rest of the JSON remains unindexed.

  6. 6

    No full-document JSON indexing exists in MySQL (unlike PostgreSQL’s GIN indexes).

Example: JSON Column with Generated Column Index

This allows MySQL to index and query details->'$.customer.id' efficiently while keeping the flexibility of JSON.

Performance Considerations
  1. 1

    JSON values consume more storage than normalized columns due to metadata overhead.

  2. 2

    Updates to JSON columns rewrite the entire JSON document, not just changed parts.

  3. 3

    Querying non-indexed JSON paths is slower because MySQL must scan the JSON document.

  4. 4

    Indexes on generated columns greatly improve performance but require planning.