I’m designing a schema where certain members can upload images (based on a permission). I’m planning on doing this using a varbinary(max) column.
What are the storage and performance implications to consider between the two following designs (apart from the obvious that the latter is one to many – that can be constrained easily enough).
- A single table with a nullable
varbinary(max)column - Two tables, one for
Members, the second forPictures
Clearly an additional left join will slow performance but if I use a single table approach will this require more storage space (I don’t normally consider storage size too much of a concern over performance but for this project I have fairly tight limits with my hosting provider).
Store the images in the same table. There will be no any storage or speed benefit of storing them in separate table, except if you’ll have zillions of members and 10 of them will have a picture.
Since sql server does not store nullable variable column at all if it has value of NULL – you even may gain speed benefit comparing two-tables design
Consider using FILESTREAM column if your images are big enough (say – more than 1 Mb). It allows to store images as files, which speeding up read-write operations, but with backup consistency.