title: How can I get relations between polygons on a postgres openstreetmap db?
body: <p>I created an openstreetmap db using <code>osm2pgsql</code>. It creates some tables, one of these tables is <strong>planet_osm_polygons</strong>. </p>
  
  <p>Other tables created by osm2pgsql are (no foreign keys are created):</p>
  
  <ul>
  <li>planet_osm_line</li>
  <li>planet_osm_nodes</li>
  <li>planet_osm_point</li>
  <li>planet_osm_polygon</li>
  <li>planet_osm_rels</li>
  <li>planet_osm_roads</li>
  <li>planet_osm_ways</li>
  <li>spatial_ref_sys</li>
  </ul>
  
  <p>Is there any way to get the relations between these polygons?</p>
  
  <p>E.g. for germany I can find the polygon <strong>Bayern</strong>. I would like to get it's parent polygon, in this case <strong>Germany</strong>.</p>
  
  <p>I know that you can find it by using <code>st_contains</code>. Is there any other way of doing it?
  If there is no other solution I will have to create these relations on my own (which takes some time), but maybe there exists something which I am missing.</p>
  
  <p>Thank you for your help!</p>