Let’s say you have a site that stores articles of different sorts.
Let’s say some articles are review articles, some are news articles, etc.
All articles have certain attributes in common - a title, a created date, an updated date, and an author ID. However, each article sub-type also has attributes specific to their type. This makes designing a single database table that works for all article types impossible without making fields that won’t be used with every record. For example, you would want a field called rating to store a numerical rating for review articles, but that field wouldn’t be used for a news article.
In a database, there could be a table called Article, that has the fields id (PK AI), title, authorId, created, updated, and type (type would specify "review", "news", etc). Then, there could be two other tables, ArticleReview, and ArticleNews. They each have a PK field named articleId, foreign key to Article. If a new review article is posted, the generic information will be stored in the Article table, and the review-specific information is stored in ArticleReview, with a shared PK value (articleId). Same with news articles and the ArticleNews table.
I figure this is a good way to avoid redundancy, extraneous fields, and also it would make a tagging system much easier to manage with a many-to-many relationship. Just two more tables would be needed: Tag (with id and name fields) and ArticleTag (articleId, tagId fields). Then, you could easily search for all articles which are tagged with a certain tag, and specify by article type if you like using the type field in the Article table ("news", "review", etc).
Is this a legitamate way to design a database? If so, how would this be implemented using Yii? Would it be possible to make a ArticleReview model class, which extends Article, which extends CActiveRecord? Then, when I run $newsArticle->save(), somehow make it update the entries in both tables?