Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to store an array for each user on my online app?
    primarykey
    data
    text
    <p>I am building a small online app (PHP/MySQL) where users can sign-up to become members, and inside the members area they have a list of quizzes they can take.</p> <p>When displaying the list of quizzes for a given user (i.e. his browser just requested the page with the list), I need to know, for each quiz, whether or not the user already took it in the past. Cause if he did I'll display a checkmark aside to it. This is to help users keep track of their usage of the site.</p> <p><strong>My problem</strong>: So basically I need to store a list of "taken quizzes" for each user. But I am not sure about the best way of doing it.</p> <p><strong>My solution so far</strong>: Each quiz has an ID, so I am planning to store the list of "taken quizzes" for each user as a string (with values separated by commas) on my database. Then when I need to use it I read the string from the database and transform it into an array (and vice-versa for storing it back).</p> <p><strong>UPDATE</strong>: Apparently there are 2 viable options: 1) is to use the method I described above storing the array as a string, 2) is to create another MySQL table to store the quiz-id/user-id pairs. At this point I am wondering which solution is faster, should the site become popular. With the first option I will have the extra work of converting the string to an array and back, but after that I'll be searching on a small array (i.e., containing only the quizzes taken by the single user). With the MySQL solution I wouldn't need to convert strings back and forth, but I would need to search on a much larger dataset (i.e., all the quizzes taken by all the users). Any guess on which method is faster for a large number of users (e.g., 1000)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload