Y
Y
Yaroslav Nikitin2014-11-24 20:35:38
PHP
Yaroslav Nikitin, 2014-11-24 20:35:38

What is the best way to store in a database?

Small numbers:
1000 - users.
100 - tasks.
What is it?
On the site, when performing a task, you need to enter into the database : a unit in the column with the task number and a row with the id of the user, roughly put a flag that the task has been completed by this user.
Question:
How to store all these values ​​more rationally? Obviously my way is the most oaky, create a table and that's it. I thought to create an array and where the enumeration goes: 001010001010, the job number, this is index-1 (from zero, the search starts if), but I thought, what if tasks are added, and they will be added, there you already need to think about how to do it, can be done with a margin.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Evlampiev, 2014-11-24
@copyloc

Usually separate tables are created: in your case, users, tasks, and tasks performed by users. The last table has columns with the user id (indexed for quick select) and the id of the completed task. In the query, you connect all this using JOIN. Recommended reading:
zlob.in/2013/01/struktura-tablic-dlya-kataloga-tov... (EAV storage structure model);
www.anton-pribora.ru/articles/mysql/mysql-join

A
Alexander Aksentiev, 2014-11-24
@Sanasol

table id, user_id, task_id, result

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question