My table lists todos. Each consists of a specific task that requires certain prerequisits (other tasks) to be fulfilled before the todo can be processed. It currently uses a simple counter (i.e. initially set to a specific number. and each completed prerequisite reduces it by 1).
tasks:
id, task
1, A
2, B
3, C
todos:
id, user_id, task_id, prerequisites
1, 1, 1, 3
2, 1, 2, 2
3, 2, 1, 3
I now want to also identify which tasks are a prerequsite and therefore thought of the following solution using a binary incrementing identifier for the tasks:
tasks:
id, task, prerequisite_id
1, A, 1
2, B, 2
3, C, 4
todos:
id, user_id, task_id, prerequisites
1, 1, 1, 7
2, 1, 2, 2
3, 2, 1, 5
I can now tell that todo still requires tasks 1,2,3 to be processed. While 2 needs task 2 and 3 needs task 1 & 3.
I know that a many-many table would be the best practice solution but is there any particular reason why above method is a bad idea?
EDIT: Being able to query for the prerequisites colum is not important. I only want to know when the column is 0. I only check the actual value in very rare cases.