title: How to remove Duplicates and update all relations from PostgreSQL database?
body: <p>I'm working on updating a local dataset that has a lot of cases with the following structure:</p>
  <p><a href="https://i.stack.imgur.com/jDBH1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jDBH1.png" alt="enter image description here" /></a></p>
  <p>The elements in table A that share the same refID for the main entity are virtually the same, so I wanna remove all these duplicates and update tables B, C and so on.</p>
  <p>The idea is to group all elements in table A that share the same refId, choose one, remove all the others and change the references in other tables to the one I chose. However, I'm having problems with the last part, updating the other tables.</p>
  <p>Is there a quick way of doing this? Doing it manually has been a pain</p>