Best way to save user entries from a puzzle to database [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have an online exam portal build in codeigniter framework with mysql database. Exam is like sudoku game each student will get 6 sudoku game in exam. At a time there will be 50 - 100 students attending the exam and each one will get different puzzles.
I developed in such a way that when student start the exam it will fetch this 6 row from database and display the UI for puzzles, each time when they enter a number in any box it will save into database.So if 100 students attending the exam that many calls will get fired into database.
So what i am facing now is when number of students is like 20 - 30 exams was smooth and if user increases i am getting connection error like "Too many connection to user" or "failed to connect to mysql database".
So what i am asking you is there any better way to store this user entries and save them at once into database like using any session( if its not increase memory usage ) or client side storage.
Please don't feel bad to read this long text, i am not asking any codes just give me some ideas or latest technologies i can learn and use to improve my application.

I think increasing/upgrading bandwidth will help you in that case...also you can check monthly visits provided by your hosting provider in your current plan.

Related

Laravel Best Practice for save user activity log in database ( with considering database Performance) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I have a website (Laravel + Mysql on top of 'dedicated server') where I save all the pages that every user sees for reporting.
My site is visited 10,000 times a day and this statistic makes the database size bigger after a few months. now 'visits' table occupied 85% of whole database!
Is there a way to do this that is the best way possible?
I have not encountered this problem before, but I think its better to take the logging with this much of heavy load out of primary database, you can move it to a file system or logging services (read this).
Or you can have job (background process) to remove the logs that you don't need Like logs from a month ago, this will help db a little bit.
Read some best practices

which is better for user activity in laravel database or log file [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
hi im thinking about user activity in laravel application ..
and i thought is it better to keep user activity in saparated log file than keep it in database ..
like create folder in storage folder for every user ..
and create log file with date like this ..
user_id_YYY-mm-dd.log
is that better thank keep logs in database
Logs on Laravel works really well to debug, but to get an history from user activity save data in database always is the best option.
You can create a log table and indexing with user_id and create reports from user activity.
querying by date, action or any other field.
Definitely store it in the database.
If you're looking to log activity, you'll end up with a large number of records and want these indexed. A few users using a piece of software for a few months can quickly generate thousands of records, depending on how detailed your tracking is.
Storing activity logs in text files will be okay in the beginning, but as soon as you want to find all actions of type X by user Y, you'll be spending hours searching through text files (or writing scripts to do it for you).

Best way to store stats of multiple people weekly [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am using the Clash Of Clans api to show all the members of the clan on a web page. But now I want to save all the donations, cups and received donations on a weekly base. So i can see in a very clear overview who are the most active members. But the thing is. I just don't know how to design the database. I was thinking to create a table every week that would look like this: StatsWeek[number]: (MemberTag, Donations, DonationsReceived, Cups). But then at some point i will have a large amount of tables. So I tought there has to be a more efficient way. But I can't think of a better way.. I am using a MySql Database
Like mentioned in the comments, it's better to store everything in a single table... you can save weekly transactions(or daily, whatever interval you choose). Here is an example schema for you.
To find, for example, troops donated on any given week; you will have to subtract the previous weeks donations from that weeks donations.

PHP & MySQL: Good/efficient of showing statistics from thousands of rows on each page load [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I know this is the wrong way to go about it, but I have a database filled with stats about vehicles that are imported from excel files.
For each vehicle(about 100 currently, updated each three days) I have from 500 to 2000 rows of data which is used to build graphs regarding fuel consumption, distance driven etc..
This is fairly simple and it takes from 1 to 3 seconds to load, but I also need the total stats and compare it against each car.
So if I build the graph for car id 1, I want to see the difference between its fuel consumption and the global fuel consumption (of all existing cars).
Is there a way of doing this without querying not only the single car but also all cars on each page load ?
Thank you
It sounds like you need to pre-compile your stats into a summary table. Write a function that takes in 1 vehicle as a parameter, compiles all your stats, then saves them to a dedicated summary table. Then write a background script that calls that function for all vehicles one by one. You can call the background script as often as you feel the stats need to be updated, leaving the web interface free to do very little computing/io.
This type of thing has saved me quite a big of headache over the years.

SQL table - Data management [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am creating a website where users can easily calculate the calories they eat and see the repartition in term of fat, carbo, etc.
I want the users to be able to retrieve data from previous days.
I then need to store the data sent by my users everyday (basically, they input how much of each food they have eaten everyday and I am making the calculation then store the results).
The question if the following: what would be the best way to store the data? I have to store the data for each user for each day. I can't think of a simple solution (I think creating a new table for each new day would not be great, would it?).
I'm using PHP and MySQL for now.
Thanks for the help!
It seems that you are a step ahead of your self with the daily breakdown question.
First, you need to decide what you need to store, e.g. fields and normalise the way they are stored.
For example, you would have the following tables:
Users:
Id
..
EatItems:
UserId
ProductId
Calories
Fat
DateTime
Once you have these tables up and running, you can build reporting layer on top of that to breakdown consumption by user / date or anything else you might be interested in.
You could have a table that holds the input/calculated data/date which relates to a user/account.
When the user views previous day's, select the data that relates to that user.
I wouldn't create a table for each day. One table would suffice.
However, I would suggest attempting something and posting the code for specific issues you have if you run into before posting here.

Categories