简体   繁体   中英

Best way to store arrays of simple data in PostgresQL

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'

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?

多对多

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM