Lacko
Lacko

Reputation: 79

Postgres Multiple Arrays

This im hoping is a simple one. but i have a table that is called product. One column is called Parts. Basically i need to store multiple arrays in there, with each array holding a reference to a part ID and the quantity required. I dont really know the best way to set it up. There could be up to about 25 parts for one product yet another have 3.

Any advice would be a great help!

Cheers Tom

Upvotes: 0

Views: 130

Answers (1)

bubba
bubba

Reputation: 3847

It seems best to setup a Many-to-Many relationship with another table and link to that. If you insist on storing the array as a string - use JSON, you can always encode your array(s) to JSON and store it as such, then when you pull it out, you merely decode from JSON back to array.

Upvotes: 3

Related Questions