6 hours ago, Josheir said:
>> (I used just files at the file system, so even a data base is not a hard requirement).
Alberth, what does this mean I'm not understanding...
Everybody always discusses server applications where the storage backend is a database. This makes it easy to fall in the trap of thinking a database is the only viable storage option for a server application.
However, a server application is still an application, so you can also do all the things that 'normal' applications can do (modulo things that would be trivially exploitable from a remote site, as the application reacts on unknown potentially hostile user input).
Depending on the application, using a data base for storage may not be the best choice. In my case, I had to load a bunch of translated strings in various languages (around 4000 strings in 50+ languages). Since translators (my users) work on one language rather than on one string, the typical access pattern would be to load many strings of a single language. Actually, "many strings" soon became "all strings", due to providing a list of "related string translations" as a service to the user (hopefully getting more consistent translations).
The database solution would be a 'language' table, a 'string-identifier' table (name and description of each string), and a table with the translations, for each language and string. Getting all strings of a language accesses the language table, and then iterates over the strings table, while getting the actual text from the translation table (actual database engines are probably smarter than that though).
Not being very happy about that solution, I continued looking for a better solution, and found the alternative to simply store all string-names, descriptions and actual text of one language into 1 file. That makes loading a language as simple as "open file, load the contents straight from the file system, close the file, done!". Given that the database is also stored in a file, My file-based solution is much quicker, since I am not looking for keys, and joining several tables. Writng is quicker too, as it's 1 file creation, and a few rename operations (with a possible remove to delete the oldest version).