kevinwwK
Convex Community6mo ago
2 replies
kevinww

array vs join table

If I have a 1:N relationship between things, should I use an array or a separate table like I would in a relational database?

eg.:
cohortsTable = [{id: "cohort1", enrollments: ["user1", "user2"]}]

vs
cohortsTable = {id: "cohort1"}
enrollmentsTable = [{cohortId: "cohort1", enrollment: "user1"},
{cohortId: "cohort1", enrollment: "user2"}]


Is there an article discussing the tradeoffs and how to decide between the two options?
Was this page helpful?