I have a table in PostgreSQL, with two columns: id and nodes. id is of type bigint, as it is the primary key in the table. nodes is an array of bigint. I would like to create a new table, where the nodes in the node arrays are the keys and the only other column is an array of ids that correspond to that node.
So let's say the original table is like this:
id | nodes
1 | {200, 300, 400}
2 | {200, 300, 400}
then the new table should be like:
node | ids
200 | {1, 2}
300 | {1, 2}
400 | {1, 2}