Saving User Images
I am doing some weekend coding exercises. I have 开发者_如何学Ca table that contains some information about, say, a customer or user. Now I want to store images for this user. I have two choices:
Save the image from user class to the same table that contains other user information.
Save the image to a new table which I can create on separate filegroup in the db and put id of image in user table (or put user id in images table).
Which is the best approach of these two, and will perform better?
I think the second approach is better. Having the blobs stored in a separate table with foreign key relation would perform better. There's also a third option: store the image on the hard drive and store the path to the image in the user table.
If your DB is normalized, then the best approach (in my opinion) will be to save images in separate table and with foreign key relation to users table.
精彩评论