Forum: Ruby on Rails Another question about database modelling

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6f3f4fcb842db4b755cd8adc8bca67c6?d=identicon&s=25 ms (Guest)
on 2008-11-06 18:03
(Received via mailing list)
Hello,

thanks for reading! :) Ich will describe my problem with the help of
an example, I think, that's the quickiest way to present my thoughts.

Let's assume, you want to save locations. Locations can be of
different types: country, federal state, town or even a shop or a
phone cell. These ways of modelling this came to my mind:

1. Create a table for each type of location, identify the common
properties and extract these to seperate tables, so that you could end
up in something like this:

Tables: 'countries', 'federal_states', 'towns' and as an example for a
table holding common properties 'demographic_information' which will
be joined with each of the mentioned tables.

2. Identify location categories, whose members have the same
properties and add a kind of type column referring to a location type
table, so:

Tables: 'cat1_locations' with a foreign key to a 'cat1_location_types'
table.

3. I could imagine to modell this polymorphic, but I've got no clear
idea right now, maybe you have heard more about this and are willing
to tell me more about this, I would really appreciate this.

Let's come to my question: Which way would you modell this? What other
possibilities are there to modell this, maybe a kind of modelling
pattern? Can you name me criterias on which my decision should be
based?

Thank you really much!

Best wishes,
ms
A442793db7f191648c2d14c934878564?d=identicon&s=25 Danilo (Guest)
on 2008-11-07 10:10
(Received via mailing list)
On 6 Nov, 18:02, ms <m...@tzi.de> wrote:
> Hello,
>
> thanks for reading! :) Ich will describe my problem with the help of
> an example, I think, that's the quickiest way to present my thoughts.
>
> Let's assume, you want to save locations. Locations can be of
> different types: country, federal state, town or even a shop or a
> phone cell. These ways of modelling this came to my mind:
>

Hi,
IMHO the best way is Nested Set, you can find a lot of tutorials
online.
This approach can represent different administrative organization in
the same time.

Danilo
This topic is locked and can not be replied to.