Placing Thumbnail Images in the Database
In my entry titled .NET RIA Data Services & Images, it was pointed out that the July Preview of .NET RIA Data Services did not handle database images stored in the database very well (it produced large files returned to the client). It was also pointed out that this situation was being addressed and would be resolved.
Placing actual images into the database is generally not a good idea. Instead, storing URI’s to the actual file in the database is generally a better idea. Using this approach, the images can be easily changed without impacting the actual database. In addition, one can avoid downloading the larger image bits if the image is not used by the application. [Note that Silverlight components, like the DataGrid, do not work with public anonymous types, so generally the entire entity, including any images, are downloaded to the client.]
So you might ask “Why did I include the thumbnail images in the database?” The answer is simple; I didn’t. I was using the AdventureWorks Lite database provided by Microsoft. In the Product table, there are two fields defined that deal with the product images:
While this design may have been OK for relational database queries, where a subset of fields could be retrieved, but it presents a problem for other technologies where the only practical choice is to retrieve all the fields.
Perhaps the best solution would be to work within Silverlight to make it possible to bind a DataGrid (or other components) to a public anonymous type (such as a subset of the properties of the Product entity).
bill