NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hello There

I am importing the database into one of my test servers and wanted to know if TAGs per ChangeSets are one-to-one mapped, or one-to-may?

The reason I ask is because I am developing the ChangeSet table on SQL, and wondered is it best to have a TAG with a ForeignKey pointing to the original ChangeSet, or can I have all possible tags are fields in the same ChangeSet tables?

I don't have any tools to see any live examples or view the data, would appreciate if I'm pointed out in the right direction.

Thanks & Regards Heider

asked 25 Sep '23, 20:58

Heider's gravatar image

Heider
16112
accept rate: 0%

edited 26 Sep '23, 12:39


Perhaps it would help to look at something that processes changesets and changeset discussions These queries are the ones that the ChangesetMD software uses to manage its database, which stores changesets, changeset tags, and in a separate table, changeset discussions.

(note the original author of this is ToeBee. not me!)

permanent link

answered 26 Sep '23, 16:39

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

Thank you very much H_mlet

I think your answer is the one I was looking for, and yes I totally understand that tags can have multiple different keys.

I appreciate your time and effort to help.

Kind Regards Heider

permanent link

answered 29 Sep '23, 21:28

Heider's gravatar image

Heider
16112
accept rate: 0%

Thank you very much H_mlet

I think your answer is the one I was looking for, and yes I totally understand that tags can have multiple different keys.

I appreciate your time and effort to help.

Kind Regards Heider

permanent link

answered 29 Sep '23, 21:28

Heider's gravatar image

Heider
16112
accept rate: 0%

You can only have one tag with "comment" as a key, but you can have multiple tags on a changeset, with different keys, eg :

<changeset id="123" key1=val1 key2=val2 ... etc>
  <tag k="comment" v="Comment-1"/>
  <tag k="comment2" v="Comment-2"/>
  <tag k="source" v="some sources..."/>
</changeset>

If you care only about the comment tag, you can store its value in your ChangeSet table. Otherwise you need to have another table with key, value and reference to the changeset (or json store as Andy said).

What you saw (I guess), on the ChangesetMD page are other comments, displayed on the changeset page under the header "Discussion". These are not tags, and are stored differently.

The xml, from the documentation, looks like this :

<osm>
    <changeset id="10" created_at="2008-11-08T19:07:39+01:00" open="true" user="fred" uid="123" min_lon="7.0191821" min_lat="49.2785426" max_lon="7.0197485" max_lat="49.2793101" comments_count="3" changes_count="10">
        <tag k="created_by" v="JOSM 1.61"/>
        <tag k="comment" v="Just adding some streetnames"/>
        ...
        <discussion>
            <comment date="2015-01-01T18:56:48Z" uid="1841" user="metaodi">
                <text>Did you verify those street names?</text>
            </comment>
            <comment date="2015-01-01T18:58:03Z" uid="123" user="fred">
                <text>sure!</text>
            </comment>
            ...
        </discussion>
    </changeset>
</osm>
permanent link

answered 29 Sep '23, 20:27

H_mlet's gravatar image

H_mlet
5.4k1781
accept rate: 13%

Thank you for the info SomeoneElse, I appreciate your help.

From the link you sent from ToeBee's work, there is another table for "comments' therefore, I have to assume that the Change-to-Comments is a one-to-many relationship and that comments can be multiple for the same change set.

Thank you very much for all your help, I will proceed with my development this way in this case.

permanent link

answered 26 Sep '23, 16:46

Heider's gravatar image

Heider
16112
accept rate: 0%

Thank you Andy

I appreciate getting back to me, so, from what I understand I can safely create a "comment" column field into the ChangeSet table knowing there will be always one comment per ChangeSet. Is that right?

i.e. there would not be the following scenario:

<changeset id="123" key1=val1 key2=val2 ... etc>
  <tag k="comment" v="Comment-1"/>
  <tag k="comment" v="Comment-2"/>
  <tag k="comment" v="Comment-3"/>
</changeset>

I think the above example explains my query better, in this case, we would only expect one comment line (which is either Comment-1, or 2, or 3) but not all Tags of similar keys getting into the same ChangeSet.

Thanks again Andy.

permanent link

answered 26 Sep '23, 16:25

Heider's gravatar image

Heider
16112
accept rate: 0%

edited 26 Sep '23, 16:27

As with nodes, ways and relations, a changeset can have many tags. Each key is unique, so there can only be one tag with the key "comment", for example.

As for approaches for storing this in a SQL database, the two main ones are to have a ChangesetTag table, with foreign keys to a Changeset table, or alternatively use a dynamic storage column (e.g. json type) called tags on the Changeset table. Both approaches are used in different parts of the ecosystem.

permanent link

answered 26 Sep '23, 15:02

Andy%20Allan's gravatar image

Andy Allan
12.5k23128153
accept rate: 28%

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×127
×101
×11

question asked: 25 Sep '23, 20:58

question was seen: 2,252 times

last updated: 29 Sep '23, 21:28

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum