Storage

7 months ago by giacholari

A decision you need to make when building a web application is that of the back-end storage - which is going to hold the data of the app. You can either store the data in the database, in the cookies, in the session or somewhere else on the web (cloud storage) or simply use a file. Not everything belongs in a database - database operations are expensive and time-consuming. Take for example the photos on this very website. I did not store them in the database. I simply stored them in the file-system. All I did is scan the file-system for files of type image, fetch them in memory and display them on the page. This is much faster since everything happens in memory (think of your RAM - you got plenty of that). However, bear in mind that this is not for everything because as your apps get more complex you will eventually need more flexibility. Then using a database would totally make sense. Another example is that of the privacy page I am building for my final year project at university. I used a JSON file to hold the data and it works quite well. If I were to change the text or title regarding the privacy policy all I have to do is modify that JSON file. On top of that, it all is under version-control and you can track back changes to the file. Point being, factors that play a role in deciding what storage medium to use are flexibility, speed, and importance of the information.