Why the use of a database?

When and why is the use of a database needed?

I am asking because I think I am about to get a price tag shocker to do what I want to do.

Currently I am using a hardcoded table of 700+ lines with filtering in plain JavaScript, from my computer is seems to be working just fine and I haven’t seen any crashes.

For some reason people have said that it would be convenient to move that data to a database to handle it.

The problem is that using MongoDB Atlas, another way to do filtering is by using indexing which I only get a certain limit to do depending on the tier I am using. They also have an option of doing compound searches, meaning I could search 2 fields at once… but if I want to create 5-,6,7, different charts, then the price start to go up pretty quickly.

So… for $400-$700 a year… do I really need to use a database to do what I want to do?

When would it be appropriate to use a database?

OK, if that works…

For some reason people have said that it would be convenient to move that data to a database to handle it.

Well, if you need to make changes, that would be easier. You could make changes and have them reflected instantly in the app. With what you have now, if this is client side, then you have to rebuild and deploy your code with each change.

How often do you have to make changes?

The other advantage of a DB is all the built in data handling. But there are JS modules that can do all that.

The other option is to have a json file, csv, or even a spreadsheet on a server and have the date served as json. Maybe you’re already doin that, I don’t know. You could even put this in an easy to access AWS bucket or something like that.

There are also free DBs, by the way.

A lot of this is going to depend on how your site is set up, what you are trying to do, and what the scale is.

2 Likes

First, no one needs to pay money for a database. There are several free ones you could use, whether relational or NoSQL.

Second, there are several pros to having a database. I’d say the top two being: (1) It separates your dynamic data from your program (which is a good thing so you don’t have to maintain 2 different things together), (2) Most databases are fault-tolerant, which is important so you don’t lose data.

IMO it’s always appropriate to use a database. The “smallest” one I’d recommend using is SQLite for small programs.

2 Likes

Yes, a database would help more if I need to make changes.

For this application I won’t need to make changes that often.

I do however want to put a good amount of information , create a good number of charts that would include filtering… and pagination…

I was moving to a database on concern of crashes… I haven’t seen any crashes on site, but people keep mentioning it…

Anyway… I am not really looking to spend $400-$700 a year just to be able to do searches, and this application doesn’t need a full CRUD operation…

I am more concern about a crash when/if it happens…

And yes… I can look into the option of creating a json file too…

It’s a good thing people pointed you towards free database options then :slight_smile:

I’m not sure I understand. Why would managing hardcoded data be prone to crashes? Whether client side or server side? I’m no expert here, I’m sincerely asking.

1 Like

That is what I understood from 3rd people… that it is better to have that data handle from a database and avoid crashes? I am not an expert either…

So, it comes the question… WHEN / WHY do I need to use a database?

Thanks… I just got to read this post.

I see you are using the word “dynamic data”… and I see a lot of applications for CRUD when it comes to databases, which I would think it would be dynamic data when you need to add and delete items from the data as part of the programming.

What would be a non dynamic data? My application is just presenting a table with a filter for searching and pagination. I won’t be adding or deleting all that much, maybe change the list once in long while, but for the most part it will just stay put.

It might help a bit if we knew more about the use case, what the app is and how the data is used.

Even with static data, it might be worth creating an API you can fetch the data from as needed on-demand (like JSON). If I as a user only need a fraction of the data but you push all of it to me that means I will have to download all the data even if I do not need it. What is your total bundle size with and without the data?

But without knowing the use case it is hard to make speculations.

2 Likes

Here is the actual sample of some the data in a hardcoded table.

^^ I want something very similar to that. Filtering a single field works Ok, but having filter on 2 fields at once, or even global filtering I think would be for easier searches, then adding pagination.

This sample chart will eventually be broken apart and expanded into separate charts, and then other charts and so on…

ALSO… I am moving the entire website into the REACT platform and build more from there. Somebody, somewhere, told me that I should put that data in a database to be more stable and avoid crashes, and so the reason why I was looking into MongoDB… until I found out the pricing to create indexes in MongoDB won’t be cheap for what I want to do…

Now, I am rethinking what would be the best approach to do something that I am just learning about how to do… maybe… just pull the data from MongoDB and do the filtering and pagination in the frontend so I don’t have to use the MongoDB indexes? Maybe put the data on a json file and pull it from there? Or just leave it hardcoded as it is and add pagination?

A backend API would still allow you to have static data structures but massage it when requested. You can filter, sort, limit, etc. before the data comes back.

Just as an aside, without testing implementations it can be very hard to know if they are the right ones. I would suggest you test it with a small data set and see how it works. Without working directly with the implementation and their abstractions it is almost impossible to get a mental view of what works and what doesn’t.

1 Like

Configuration data is probably the best example of static data - i.e., almost anything that’s traditionally stored in a JSON file.

Most web apps have users though, and anything relating to users (usernames, passwords, email, etc) should be stored in an actual database.

Btw, MongoDB has a free tier, no need to pay for it unless you have additional demands.

2 Likes

Thank you to all…

I think I can either just pull the data from MongoDB, or just put it in a json… then do the pagination and filtering on the frontend… staying away from the MongoDB indexes will save me some money for what I am looking to do…

The advantage of a database is that it’s easier to update the data, easier to structure the data, easier to query the data using built-in functionality. But if it’s definitely read-only and isn’t ever really going to change then, yeah, just do that, you’re just overcomplicating things otherwise. You’re saying there’s about 700 rows: that’s a small amount of data, so just load it all when you run your code. Then you can filter/map/whatever over it freely.

Re databases, I’m not quite sure how, money-wise, you’re coming up with the figures you’re coming up with: you have a minscule amount of data, should be free or very close to free.

Databases are beneficial in lots of distinctive situations for storing statistics. It is standard to apply a database while distinctive units of statistics want to be connected together, including:

Pupils in a college and their grades
Customer facts and income information
Patients’ and doctors’ facts
Transactions among distinctive financial institution accounts
Taxpayers and profits tax payments
The 3 important benefits that databases have over different, less complicated statistics garage systems (including textual content documents and spreadsheets) are getting admission to, integrity, and security.

Access

Access is ready making statistics to be had to customers.

Databases assist suitable statistics to get admission to because:

Large volumes of statistics may be saved in a single place
Multiple customers can examine and adjust the statistics on the equal time
Databases are searchable and sortable, so the statistics you want may be discovered brief and easily
The statistics shape is extendable and may be changed as necessities extrude
Integrity
Databases can make sure that the statistics contained inside them are correct, or has integrity.

To make sure the integrity of a database, every extrude or transaction have to comply with a fixed of regulations referred to as an ACID:

Atomicity: while converting statistics inside a database, if any part of the extrude fails, the complete extrude will fail and the statistics will continue to be because it turned into earlier than the extrude turned into made; this prevents partial facts from being created
Consistency: earlier than statistics may be modified in a database, it has to be tested towards a fixed of regulations
Isolation: databases permit a couple of adjustments on the equal time, however, every extrude is remoted from others
Durability: as soon as an extra has been made, the statistics are safe, even withinside the occasion of machine failure
In addition, databases can have mechanisms for backup, distribution, and redundancy, to make sure statistics isn’t always lost.

Security
While getting admission to textual content documents or spreadsheets may be secured, as soon as a person has gotten admission to a file, they’ve to get admission to all statistics inside that file. Databases may be made very secure, and that consists of the capacity to have to get admission to rights to precise elements of the database and now no longer others.

Databases permit get admission to be controlled, permitting customers to have distinctive privileges: for instance, a few customers can be capable of examining statistics, however now no longer to jot down it.

Data also can be segmented in order that customers can get admission to handiest sure elements: for instance, a consumer can be capable of examining an employee’s call and deal with however now no longer their profits information.

What different makes use of for a database can you believe you studied of? Share your mind withinside the comments.

In the subsequent step, you may discover an instance relational database and study the statistics contained inside it.

1 Like