views:

36

answers:

2

I am doing some weekend coding exercises. I have a table that contains some information about, say, a customer or user. Now I want to store images for this user. I have two choices:

  1. Save the image from user class to the same table that contains other user information.

  2. 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?

+2  A: 

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.

Darin Dimitrov
+1  A: 

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.

Valery