I am building a site for a magazine that includes three different sections- articles, blog posts, and reviews. All three of these object types have the following columns in common: title, description, headline, subheadline, body, and author. Should I store them each in their own table, or should I just create one Posts table and add a category that allows me to distinguish between [‘article’,’blog’,’review’]?
Just to be clear- each of the three of these will be presented to the user in a completely different visual format, so it’s not like it’s just a blog with categories or tags of article, blog, and review. But should it be like that behind the scenes?
Having a hard time deciding if I should split them up solely based on the fact that they are in fact separate objects, or keep them all together to keep my app DRY. Will that cause a maintenance issue down the road? Performance issues? Normalization? Data Integrity? I’m not a DB guy, so any help is greatly appreciated.
I don’t think it matters at all, but I’m using Rails, so I’m trying to figure out if I’m going to end up with 3 different controllers, 3 models, and 12 views, which I’m happy to do if there’s a good reason behind it.
Thanks in advance!
I would recommend adding a column to indicate the type. If you call it type this will allow you to move to Single Table Inheritance (also here), even if the models begin to diverge slightly. You would then end up with…
You can use Post in most cases, and a single Controller, but then use inheritance to handle special behaviors such as validations.