This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Relation members structure for DB

0

How to correctly represent relation members in Mysql DB? I see two variants:

  1. One table "rel_member" with ordered member list of different types with discriminator column.
  2. Three tables "rel_member_rel", "rel_member_way", "rel_member_node" for each corresponding object type.

For me second variant is preferable, but does it retain OSM semantics?

asked 17 Jan '15, 22:26

ikoder's gravatar image

ikoder
11112
accept rate: 0%


One Answer:

1

Depends on what you want to achieve. Relations are ordered in OSM so if you ever plan to upload something again, or otherwise accurately represent OSM's data, you will have to retain the order of elements. In your #2, this would have to be implemented as a separate sequencing column.

For most interpretation purposes, e.g. for the drawing of routes or multipolygons, the order does not matter. osm2pgsql, for example, uses a variant of your #1 schema but instead of a discriminator column, stores all member object IDs in a linear list - nodes first, then ways, then relations - and uses only two additional integers to point to the beginning of the way IDs and the beginning of the relation IDs in that list.

answered 18 Jan '15, 01:38

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Source code available on GitHub .