Using ActiveRecord I would create 3 models: Baseobject, Assembly, Part. I think this would result in a complicated model handling. Especially when creating/reading/updating/deleting/searching a model. Because I always need to take the related models in account.
The usual way to store it is to have a single table for all items, let us call it Component. This table has a column for type (0=part, 1=assembly) and then columns for all of the properties of both types, some of which will be null if they don’t apply. There will also be a self-referencing key column called parent, which contains the row id for the Component that is the parent - or null if it is a top level item. When loading parts from the database, you can easily see if type=Assembly, you need to subload the parts and assemblies where parent id = current id and then if it is type=Part, you just load itself.
I think Yii will take care of the relationships if you setup the foreign key correctly in your database.
Thank you! The method you described about the relation with child/parent is perfect! But now I am a little bit confused: is it really best practice to use just ONE table for all different types (parts, assemblys,…) ?