I’ve read multiple places that you shouldn’t store arrays in a mysql db. So I thought I’d ask how I should go about doing this:
I’m writing a basic task management app in php/mysql, and I want to have projects and tasks. A task is a single object, where a project is an object that holds multiple tasks. So I already have the tasks working, I have a task table with id, name, dueDate columns. My next step is the projects.
My plan was to have a project table with id, name, dueDate, and taskID columns. The taskID column would either hold an array of task IDs or possibly just a string with comma delimiters.
Any suggestions?
This is called a one-to-many relation in MySQL. You would have tasks that hold the id of the project they are assigned to. So to find the tasks associated with the project, you would simply query for all tasks that are holding the project id. Does that sound right?