MYSQL. How do we better maintain the user data?



  • There's a MYSQL in it, and there's a table containing the names of the files and the references to them, and I need to keep the data on the user that he downloaded. I think it's possible to set up a table for every user and keep all the names of the files he's downloading, but I understand it's too shy in that it's like over 60,000 tables that can't be made in mysql. Any other options?



  • Best store all user files in a single table, for example, mediafilesEach user file shall be marked with an external key where the user identifier is stored

    Table users

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

    Table mediafiles

    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 it's about downloading files, then you'd better start another table. downloadswhich connects usersuser_idand downloaded files (file_id)

    Table downloads

    id user_id file_id
    1  1       27
    2  1       1123
    3  2       12
    4  2       8
    5  3       84
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2