I'm looking at file upload gems and there seems to be a tendency to put all assets in single "Assets" table and using STI to subclass them. Like ImageAsset
, VideoAsset
, AudioAsset
, etc.
I'm new to Rails and I've never used STI. Previously I would have just made images
, videos
, audios
separate tables. Granted they may share a few columns but I'd say they'll also have some different ones (sample rate doesn't apply to image, e.g.)
Pros of stuffing all this in one "assets" table: easier to run queries on all assets. Cons: table is going to get bigger quicker. I guess I could always shard on the "type" column if that's a problem. Also I anticipate all the audio-only columns will be null on image rows, etc.
My whole app is going to be based around assets so I want to make sure I have the pros and cons straight before making a decision. Has anyone done STI assets and regretted it? Has anyone done it and not regretted it (for a large amount of assets)? Would CTI (class-table inheritance) be a better solution here?