I have a table where i want to store data for Favorites games. It will store iser_id and game_id. So when user login to i have query for displaying the game_ids for the user who is logged in (user_id) Which is better? To store for every game new row, (1 user has 10 games that means 10 rows) or ne row for every user and fiels for the games example ID_USER GAME_ID 1 10,50,1,1024 Suggestions?
The first idea is a much better and scalable database structure. Generally you would want to have a user table, and then a second table with an individual entry for each game that each user has. Basically: Users_table: user_id other_user_info Games_table: id (auto incrementing) user_id game_id Also if you want to keep your data accurate, and free from dead entries, put a foreign key on the user_id in the games table.