I am slowly teaching myself PHP and MySQL and I would like to have a database with a table of users and a table of items. On the website users will be able to have a saved list of the items they own (from the table of items) that they could rate and comment on ect. I would prefer to have the items table seperate and be able to add more features to them later on (descriptions, avg. ratings, ect.) as opposed to just having a massive table of duplicate items from users owning the same things.
For this I would assume I need a separate table holding the foreign keys for both the user_id and the item_id's they own. The problem is theres no way to determine how many items each user will own and there are alot of items (2000+) and they will be able to add new items to this list.
The question is how do I handle this? For the separate table holding the keys, would I need multiple columns for each new item key added by the user? This seems inefficient but I am new to this so I may be wrong. Or would I have a user_id column an item ids column holding an imploded array of items keys? And if this is the case would I have to use a foreach loop to run through each key and call the database each time? This also seems inefficient but less so than the alternative stated before. Are there any resources I could read about this or any tutorials ect? Or are there any features in PHP or MySQL that I don't know about that could help handle this situation? Thanks!
For this I would assume I need a separate table holding the foreign keys for both the user_id and the item_id's they own. The problem is theres no way to determine how many items each user will own and there are alot of items (2000+) and they will be able to add new items to this list.
The question is how do I handle this? For the separate table holding the keys, would I need multiple columns for each new item key added by the user? This seems inefficient but I am new to this so I may be wrong. Or would I have a user_id column an item ids column holding an imploded array of items keys? And if this is the case would I have to use a foreach loop to run through each key and call the database each time? This also seems inefficient but less so than the alternative stated before. Are there any resources I could read about this or any tutorials ect? Or are there any features in PHP or MySQL that I don't know about that could help handle this situation? Thanks!