I would go database. Arrays of data work fine for small things, but if youre looking at a lot of data, a database is going to more efficient and easy to deal with. I have a similar project that uses massive amounts of data and I can get most of it with a single database query. I organized it so that I have one main table (maybe country in your case) that has relationships with all the other tables. You could also use joins effectively in this situation I think.
How to handle large amounts of supporting data?
Hi folks,
I'm working on a project where there is lots of data that I need to store and use for lookups. An example of this is unemployment rates by county for the entire nation for the last ten years. Its a lot of data points and I'm trying to figure out the best way to handle it in Laravel.
Here are the options I think I have. Can anyone suggest better solutions or confirm that one of these is good and comment on whether its architect-ed right or not?
Thanks in advance to all who post!
Option 1: Create utility files that house arrays of data. Jefferey Way did this in one of his training videos for the state names and abbreviations. He threw them in a utility class and then injected them into the view as needed.
Option 2: Create a database table and store all the data on the table. This is how I would normally do it, but I'm concerned with the number of queries, the size of the results being returned and the speed and performance of this approach vs option 1 and pulling from the server (which has SSD drives).
Are there any other options? Also if I go with option 2, i think ideally I would want to create a seeder to load all this data at the start of each server to make sure the database is seeded with this supporting data.
Any help or advice anyone can give that might have done something similar would be greatly appreciated.
Thanks again!
I wrote up how I used LOAD DATA LOCAL INFILE for the seeding of reference data. You may find it useful: https://tenerant.com/blog/using-load-data-local-infile-in-a-laravel-migration/
Please or to participate in this conversation.