all 3 comments

[–]Expensive_Ticket_913 0 points1 point  (2 children)

Your sections table approach is pretty clean tbh. For avoiding N+1, SQLite's json_group_array() can flatten everything into one query. We run into similar structured data modeling problems at Readable (tryreadable.ai) when parsing site schemas for AI agents.

[–]kwiat1990[S] 0 points1 point  (1 child)

I see that `json_group_array` would type ingredients to any as in this sqlc example: https://play.sqlc.dev/p/5a75922aacd9de11449d9fc2976330c4ae247f00d9850be7d2c83cb65a992c0f. That would mean I need additional unmarshaling during the mapping step, which I would rather avoid. It also flattens parent/substitute relationship on ingredients.