liveBook · Manning

Array column

As explained in Spring in Action, Sixth Edition

An array column is a database table column whose value contains an array of elements.

An array column stores multiple values inside one database table column. In reactive persistence, it can represent related entity IDs when direct relationships are unavailable. section 13.1.1

Storing taco ingredients

A Taco entity keeps ingredientIds as a Set<Long>. Its addIngredient method adds an Ingredient ID, while the Taco table stores those values in an ingredient_ids array column. H2 and PostgreSQL support array columns, although array entries may not enforce foreign-key integrity. section 13.1.1

Choose an array column with these trade-offs:

  • Use it to persist collections of related IDs when the database supports array types. section 13.1.1
  • Recognize that many databases lack array support, and supported arrays may not provide referential integrity. section 13.1.1

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains the design trade-offs and shows entity and table mappings, but stops short of detailed query operations.
Examples
Uses Taco ingredientIds, addIngredient, and the Taco ingredient_ids array column.
What it assumes
Assumes database tables and entity relationships, while explaining the relationship limitation from the beginning.
What you can do after
Apply array columns to persist collections of related IDs in a reactive entity model.
How it connects
Connects array columns with Spring Data R2DBC, entity relationships, related IDs, and referential integrity.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.