Rails port/Database schema

From OpenStreetMap Wiki
< Rails port(Redirected from Old database schema)
Jump to: navigation, search
Available languages — Rails port/Database schema
Afrikaans Alemannisch aragonés asturianu azərbaycanca Bahasa Indonesia Bahasa Melayu Bân-lâm-gú Basa Jawa Baso Minangkabau bosanski brezhoneg català čeština dansk Deutsch eesti English español Esperanto estremeñu euskara français Frysk Gaeilge Gàidhlig galego Hausa hrvatski Igbo interlingua Interlingue isiXhosa isiZulu íslenska italiano Kiswahili Kreyòl ayisyen kréyòl gwadloupéyen kurdî latviešu Lëtzebuergesch lietuvių magyar Malagasy Malti Nederlands Nedersaksies norsk norsk nynorsk occitan Oromoo oʻzbekcha/ўзбекча Plattdüütsch polski português português do Brasil română shqip slovenčina slovenščina Soomaaliga suomi svenska Tiếng Việt Türkçe Vahcuengh vèneto Wolof Yorùbá Zazaki српски / srpski беларуская български қазақша македонски монгол русский тоҷикӣ українська Ελληνικά Հայերեն ქართული नेपाली मराठी हिन्दी অসমীয়া বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල ไทย မြန်မာဘာသာ ລາວ ភាសាខ្មែរ ⵜⴰⵎⴰⵣⵉⵖⵜ አማርኛ 한국어 日本語 中文(简体)‎ 吴语 粵語 中文(繁體)‎ ייִדיש עברית اردو العربية پښتو سنڌي فارسی ދިވެހިބަސް

This is Developer documentation on how the various database tables are laid out in OpenStreetMap's core rails app, the rails port. This database stores all data relating directly to the openstreetmap web site and API, and most importantly the geodata tables hold the actual map data, that is the Data Primitives (nodes/ways/relations/tags etc) and their editing history.

Schema changes are carried out occasionally in form of rails "migrations", and so the migrations definitions in git should be regarded as the "one true source" for schema definitions. In fact there is, at least in theory, little need to understand the underlying database schema, since code interactions within rails app take place via the rails models (ActiveRecord), and data interactions by third party tools take place via the API. However, if you're developing on your own test server, you may be curious to know how the underlying database is structured.

The latest version of the database schema can be found in the Rails port git repository.

A detailed ER Diagram of the schema supporting the RailsPort can be found here (created 12/2014)

Tables

Geodata tables

There are two tables for each set of Data Primitives: the master table and the current table.

The current table (e.g. 'current_nodes', 'current_ways') is the latest revision, used for drawing the map. The master table includes all previous edit history. The current table is therefore a subset of the master table.

Latitude and Longitude are stored as scaled integers with a scale factor of 1e7, so an integer latitude of -412870685 equates to -41.2870685.

Diagram

OSM DB Schema 2016-12-13.svg