tzookb's avatar

handle user images conventions

Ok so I have a mini social site where users can upload images to their profile, post posts with images, and have a profile image.

Now the uploading process is not a problem, my discussion is how to store the reference to the user uploads and interact with it?

I mean one big table of user uploads, with column of type of image or how would you handle it?

0 likes
2 replies
pobble's avatar

I'd have an image table that stores the image file name rather than an image column

Devon's avatar

I'd have a media table with a row for each image... I'd store things such as a title, description, gallery_id, user_id, and some form of random hash or token for the filename.

Then you can have a avatar_id column or something in the users table to associate their user profile image... Or, if you prefer to keep media separate from the users, you can add an is_avatar column to the media table.

Please or to participate in this conversation.