I am looking for some direction on how the most efficient way to structure my database for users on my website.
Essentially, I already have a “tblusers” database that includes basic biographical information, such as:
tblusers:
UsrID, First, Last, DOB, Phone Number, etc.
However, one aspect of my website includes (will include) an area where users can upload multiple pictures of themselves, out of those pictures they can select one to be their default ‘profile’ picture. Moreover, they can also “crop” any one of their photos to create a “thumbnail avatar” as well.
So basically, I am looking for some help on structuring a table(s) for use of: 1)Multiple pictures, 2)Ability to change default profile picture, 3)Ability to create and use thumbnails/avatars. I’m thinking this will be somewhat based on that user’s “usrID”, but I’m not sure of the best way to format the table.
Lastly, any suggestions on how to maintain the “file structure” of all the pictures that will be uploaded to different profiles would also be helpful.
Any help would be great! Thank you.
I would create a table for users’ images with flags for avatars and profile… (Or create multiple tables for images and avatars)
It depends on how much data you want to store in there. The above allows for any number of images to be owned by one user.
Personally, I’d likely create a folder structure that uses a users id as its base dir;
Then you wont need to specify a path in the db, you can create it dynamically using the users’ id (i’d keep the user directories as integers too, not using ‘user’ that was just to demonstrate).
Hope that helps, let me know if you need any more help.