one model for 2 tables

I have a table "news",and a table "news_video"

I have created model News, what I want now is: Create NewsVideo model that have some fields as News and plus others ( like NewsVideo inherits from News), Because there are some others table related to "news". So if I create NewsVideo separately, I have to create more tables in the database, I have searched on google but could not find any,

    How can I change this code into what I need 

/**

	 * @return string the associated database table name

	 */

	public function tableName()

	{

		return 'tbl_news';

	}

Thanks all,

here :table inheritence

and this article will help you :class inheritence

this topic is useful too table inheritence

Way 1. You could simply extend NewsVideo from News




class NewsVideo extends News {


        public function tableName()

        {

                return 'tbl_news_video';

        }


        ... 

        // define new or extend exists rule

        // and so on

}



Way 2. Refactor news and news_video table, like

news


id

field1

field2

news_video


id

news_id

additional_field1

additional_fields





class News extends CActiveRecord {


    public function relations()

    {

	return array(

        ...

	    'video' => array(self::HAS_ONE, 'NewsVideo', 'news_id'),

			

	);

    } 

}


class NewsVideo extends CActiveRecord {

  ...

}


// usage

$news = News::model()->findByPk(1);

// get related video

$news->video->additional_field1;



In mostly cases I’d prefer second way.

thanks yiiquing, but seems that I can not find out a solution from it. ^^, I’ll try on it more.

thanks weavoraTeam,I’m now trying the first one, but some problems raise when I try to find, insert,

The second is much is easier but I have some tables related to news, so If I follow this way, I have to create more tables in the database.