0

When should I use Active Record's database and when should I use a JSON/YAML/XML (whatever) to store data that won't be changing like list of countries and states or (in my case) spells list.

Something like:

[
    {
        "name": ...
        "require level": ...
        "school": ...
    },
    {
        "name": ...
        "require level": ...
        "school": ...
    }
]

Thank you.

Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75

1 Answers1

1

For data that won't be changed you should always use YAML/JSON/XML files and not store the information in the database.

Reading data from the db is much slower, so try to avoid it.

In a case that you are not so sure if the data will change or not/you know that the data will change but not often - i would suggest not to use the database as well (thats what i'm doing).

i would recommend to use YAML file, but thats a different topic. you can read about Yaml Vs Json

Community
  • 1
  • 1
Ziv Galili
  • 1,405
  • 16
  • 20
  • Some would say "Never say 'never'". It's not difficult to create a model for those values, and restrict it's modification to an Admin user. If performance is an issue, cache the data once it's read. – railsdog Feb 05 '15 at 05:15
  • Performance sure won't be an issue. Even so, is it better to use a file instead of the database? Which one would be easier to manipulate? – Rodrigo Ruiz Feb 05 '15 at 18:47
  • it depends on the manipulation needed, and if it will be often or not. file - you need to upload to the server when u finish editing / login to the server and edit it there. database - you can edit from your site... you said that the file won't be changing, in that case go for a file. – Ziv Galili Feb 06 '15 at 01:50