There is a MYSQL in it there is a table with file names and links to them, I need to save data about the user which files he downloaded. I think when creating the registration, it’s possible to create a table for each user and save all the names of the files that he downloaded, but I understand that this is too hard in the sense that more than 60,000 tables cannot be created in mysql. Are there any other options?

    1 answer 1

    It is best to store all user files in a single table, for example, mediafiles , with each user file marked with a foreign key in which to store the user ID

    Table users

     id name 1 Первый 2 Второй 3 Третий 

    mediafiles table

     id user_id path 1 1 img1.jpg 2 1 logo.jpg 3 2 hello.jpg 4 2 logotype.jpg 5 3 my.jpg 

    If we are talking about downloading files, then it is better to create another downloads table that will connect users ( user_id ) and the files they downloaded ( file_id )

    Table downloads

     id user_id file_id 1 1 27 2 1 1123 3 2 12 4 2 8 5 3 84 
    • And how much maximum can you make in one table? - Andrei
    • @Fasd Everything rests on the primary key, for the INT type its size is 4294967296 for the BIGINT type - 18446744073709551615. It is difficult to exceed them, but if you exceed them, you can abandon the numeric primary key and switch to a string key based on several columns. - cheops pm
    • @cheops why not to throw out the surrogate key at all? There records will only be inserted , they will not change. - D-side
    • @D-side, I agree, you can consider this option. - cheops