Home > Blockchain >  Best way to store arrays of simple data in PostgresQL
Best way to store arrays of simple data in PostgresQL

Time:10-08

I am creating a database where one of the 'user' tables needs to have an array of foreign keys linking to multiple rows of another table. I'm trying to figure out the best way to handle this.

user projects
jeff [1,2,6]
dave [3,4]
projects otherstuff
1 'content 1'
2 'content 2'
3 'content 3'
4 'content 4'
5 'content 5'
6 'content 6'

The framework I am currently using (AdonisJS) for building tables doesn't seem to allow for this, so I'm trying to find a work around. I guess could make a table for every user called 'user_projects' but if I have 10k users, it seems frustrating to have 10k tables with redundant rows if each some users work on the same project.

Thoughts?

CodePudding user response:

Many to Many

With the many to many relationship. Here is the ERD diagram.

  • Related