I store different items (notes, articles, pictures, files) in a single table (there are many metadata in common for all the item types - for example, categories, tags, rating, statistics etc.).
My first design was like this: table Items, plus another "detail" table for each of the item types (NoteItems, ArticleItems, PictureItems etc.). To retrieve a single item, tables must be joined one-to-one (SELECT * FROM Items INNER JOIN PictureItems ON Items.Id = PictureItems.Id WHERE Items.Id = N).
I'm pretty sure that this "by-the-book" design would work nicely (done that several times), however, I start to wonder whether the design is overkill. It would be much simpler to have a single table (Items).
Let's say that there are about 5% of items of picture or file type.
And now, the question: if I go for the (almost) single table design, would it be better to have detail tables for image fields anyway (for picture and file items, of course)?
Scenario 1: only one table: Items (for storing notes, articles, pictures, files...)
Scenario 2: two tables: Items (for storing notes, articles, picture files), ImageItems (for storing only image field of item types picture, file); one-to-one relation
(Scenario 3 would be a minor variation of Scenario 2; with 3 tables (Items, PictureItems, FileItems))
Advantages of scenario 1 are:
- simpler select queries (no joins)
- transaction-less updates (only one table is updated on INSERT/UPDATE)
- performance, scalability due to transaction-less updates?
Advantages of scenario 2 are:
- cleaner design
- lower data consumption (in scenario 1, about 95% of items of type other than picture or file would have NULL value in the image field, that's about 16 bytes wasted for the pointer)
Which scenario would you choose: 1 (transaction-less updates) or 2 (lower data consumption)? Thanks for your opinions.