Reputation: 99
I have basic knowledge in PHP and MySQL.
Im trying to build an application for employees working with a weekly task list. I have a working application for other duties with user login etc. so I need this "task list application" to be integrated.
I have an idea how to do this in a bad way, so I need your help to be "pushed into right direction" =)
Every task list is stored for statistics etc.
Right know my table kind of looks like this (real table contains 50+ tasks):
ID || userID || task1 || task1description || task2 || task2description || timestamp
Right now I have set "Standard value" in the description fields, for describing the task. The reason for this is that I want to echo the full task list in a while loop.
I suppose there is a much better way to do this? Above solution works but my table gets very large because every row contains the descriptions. Another solution is to manually write descriptions in HTML, but I want everything to be dynamic.
Plz help! =)
Upvotes: 0
Views: 880
Reputation: 160
Have multiple tables and use foreign keys. You should normalize your database.
For instance have a table users
that contains a user_id
, username
, pherhaps password
etc.
and have a separate table that tasks
which has columns task_id
, task_name
, and task_description
Then have a table to link them together user_tasks
which has just two columns user_id
and task_id
This way you can assign users (more than one if you need) to tasks
Use foreign keys in your user_tasks
table to ensure that that only valid user_id
s and task_id
s are used on your user_task
table
example tables: Users:
user_id || user_name || password
12 || jim || Il0vecATS
13 || jane || jimsuzx
Tasks:
task_id || task_name || task_descr
1 || clean up || sweep the kitchen
User Tasks:
user_id || task_id
12 || 1
Jim is in charge of sweeping the kitchen
Upvotes: 2