TheVillageIdiot
TheVillageIdiot

Reputation: 40527

Saving User Images

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?

Upvotes: 2

Views: 141

Answers (2)

Valery
Valery

Reputation: 378

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.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1039298

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.

Upvotes: 3

Related Questions