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 9 years ago.
Improve this question
I need to create a quiz site and I'm not sure about how should I proceed with statistics. The site needs to track each users progress (which answer was answered how, how many time does it take to answer each question etc).
Should I create a new table (let's say 'statistics), and should I create a new row each time a user has finished a quiz? So, statistics:
user_id
quiz_id
answers (in serialized form, because the amount of questions is variable)
time_of_answer (same as above)
points_for_each_answer (same as above)
Wouldn't this be too slow, if the admin wants to check some stats, let's say: how many users have correctly answered the question #2 under the 3rd quiz?
Don't serialize answers if you need them as a real entity - just give them a quiz_id foreign key so you know to which quiz they belong, use proper indexes, and everything will run smooth.
Related
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 21 hours ago.
Improve this question
we are creating an e-learning website with Laravel, and we have multiple users (student, instructor, admin) should we store them in one table (users) or each user with own table.
I want to know if there is a convention
There is no set in stone rule, it is totally up to you. But from what I see in most Laravel projects, and what I do in my projects as well, to make it easier to read/troubleshoot you use a single "users" table and make a "profile" or "profile_type" column to determine which one are they attached to.
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 11 days ago.
Improve this question
My goal is to add pictures inserted by user into a database. So I'm trying to set their names to the date of their creation. The format is "day.month.year hour.minute.second". But I'm facing the problem that the only one picture is added to the catalog. I'm thinking that the reason why it happens is because the script runs too fast for a second to pass.
And that made me think if this is a good idea to name pictures this way.
I started to assume that maybe I need to use some kind of library to manually add a second to every next picture's name.
But before doing that I decided to go ask somebody more profecient than me in order to undesrtand whether I need to do it this way or maybe there's a better one
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.
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 7 years ago.
Improve this question
I'm building a php web app that requires to create an invoice, where its ID must be incremented (e.g: 15235, 15236, 15237,...etc). It all works fine with 1 user creating the invoice. The the issue arise when there are more than 1 users hitting the create button at the same time. Supposedly the next incremented ID is 15230, and having 3 users hitting the create button the same time, the app will return 15232 to all 3 users.
FYI, I store the last used ID in a database and increment it when users create an invoice.
Does anyone has any solution? Your suggestion is much appreciated.
Simply use built-in mechanics and define ID field as AUTO_INCREMENT.
You can read more about that here.
After that just skip ID in your INSERT queries and database will take care about that for you.
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 9 years ago.
Improve this question
I have a database / systems question.
Say you have a CMS system done in PHP and Mysql
When you have users who edit their details, do you just update their row with the changes or do you keep a history for example by updating their row by setting the column 'status' = H (For History) and insert new row with all the old & new changed details with column 'status' = A (For Active) and that becomes the primary row?
I would just like to know what other developers do?
I'd keep a history for audit purposes but I'd move old records to a history table to prevent problems with primary ids. I wouldn't keep old records in the same table as current, that's just too much redundant data.