NOTICE: is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum

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

accept rate: 0%

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.

permanent link

answered 18 Jan '15, 01:38

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 17 Jan '15, 22:26

question was seen: 2,309 times

last updated: 18 Jan '15, 01:38

NOTICE: is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum