Putting that in the database would make the most sense to me. The time to access a database is usually equal to or less than the time to load a text file. In addition, it would only take ten to twenty minutes to build the scaffold you''d need to edit / add / delete apartment or building information. Duane Johnson (canadaduane) On May 29, 2005, at 2:56 PM, Matthew Margolis wrote:> I have a three level deep hierarchy building > apartment > room. > The listing will only change once a year and will consist of a > hefty number of subtractions and just a few additions. I will be > using each level in the hierarchy as a limiting factor in choosing > which items to show from the level below it in an option select box > in a form using some ajax. > > So to start you would have a drop down labeled building. If you > choose building ''10'' an ajax request will be made that will create > the code to render a drop down that lists all the apartments in > building ''10''. When you chose the apartment an ajax request will > be made that will render a drop down list with all the rooms in > that specific apartment. > > With this knowledge how would you recommend that I store my > hierarchy in my application? It doesn''t change very often so I was > thinking that maybe I should not throw it in the db. If I keep it > purely in code as some sort of class or hash structure then I won''t > have to hit the db so often and initial setup could be done inside > of a text editor as opposed to the having to use funky sql syntax > or slow phpmyadmin record entry forms. > > > Thank you, > Matthew Margolis > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Simon Willison
2005-May-29 20:52 UTC
Re: Which data structure to use for semi static data?
On 29 May 2005, at 21:29, Duane Johnson wrote:> Putting that in the database would make the most sense to me. The > time to access a database is usually equal to or less than the time > to load a text file. In addition, it would only take ten to twenty > minutes to build the scaffold you''d need to edit / add / delete > apartment or building information.+1. Don''t forget, premature optimisation is the root of all evil: http://c2.com/cgi/wiki?PrematureOptimization
I have a three level deep hierarchy building > apartment > room. The listing will only change once a year and will consist of a hefty number of subtractions and just a few additions. I will be using each level in the hierarchy as a limiting factor in choosing which items to show from the level below it in an option select box in a form using some ajax. So to start you would have a drop down labeled building. If you choose building ''10'' an ajax request will be made that will create the code to render a drop down that lists all the apartments in building ''10''. When you chose the apartment an ajax request will be made that will render a drop down list with all the rooms in that specific apartment. With this knowledge how would you recommend that I store my hierarchy in my application? It doesn''t change very often so I was thinking that maybe I should not throw it in the db. If I keep it purely in code as some sort of class or hash structure then I won''t have to hit the db so often and initial setup could be done inside of a text editor as opposed to the having to use funky sql syntax or slow phpmyadmin record entry forms. Thank you, Matthew Margolis
Sebastian Kanthak
2005-May-30 18:44 UTC
Re: Which data structure to use for semi static data?
Matthew Margolis wrote:> With this knowledge how would you recommend that I store my hierarchy > in my application? It doesn''t change very often so I was thinking > that maybe I should not throw it in the db. If I keep it purely in > code as some sort of class or hash structure then I won''t have to hit > the db so often and initial setup could be done inside of a text > editor as opposed to the having to use funky sql syntax or slow > phpmyadmin record entry forms. >you could put it into a YAML file that is loaded upon startup of your application (e.g. from environment.rb). This way, you only need to parse the file once. Of course this means, you''ll have to restart your webapp whenever you change the data. Sebastian