I'm doing some php/mysql work and started to wonder what would be more efficient and what method would have better data integrity.
I've never used method #2 but i have seen it used in systems like a CMS or eCommerce. I use #1 regularly.
Example: When creating a "task" in my system I need to assign 1 OR multiple users to it.
Method #1 In this method I would have a table which would store both task_id and user_id. I would query this table to get the relationship.
Method #2 In this method I would have a column in the task table "users_assigned" this would store a serialized array which I would unserialize when I needed to. e.g.
$data = array('John', 'Jack', 'Jill');
// after serialization it would look like...
// a:3:{i:0;s:4:"John";i:1;s:4:"Jack";i:2;s:4:"Jill";}
What method is best for storing this type of data in a database?