Search code examples
javascriptrdbmsdata-storage

Advantages of different data storage types and when to use it?


I am a coding beginner and I need help deciding on the way I will store data for the website I am building. I have a section on my website where I will be listing items. Each item will have several properties. I was thinking between javascript objects or storing the item and the item's properties in a database. What are some situations where I should use a database, js objects, or view files? Any advantages of each type? Also how about when you are trying to sort the items?


Solution

  • You should store data in your database Only When you need !

    • If you don't have any logic process on this data in your server, there is no need for storing in database, So just store in your View files.
    • Also if you don't need this items in your javascript code so don't store them in js file ! just write them wherever you need.

    EDIT :

    If you have some operations like sort, order and etc :

    • If your data will have many changes and process it's better to store in database.
    • If your data will not have many changes and is some constants, so just stroe them in a javascript object.