I don’t think it’s possible to let the AR system handle that automatically. A simple solution could be to add a getVlan() method to your house model (which gets the lan by attributes + with vlan, after which you can return lan->vlan). However, if you have pages with a lot of houses on for which you need the vlan displayed, it could result it a big number of queries.
If you do want everything to happen automatically I’d suggest remodeling your database by either
adding a lan_id to the house table
creating a new table location(id,switch,port) and replace the switch & port columns in house and lans by a location_id (this would be my preferred method, since it’s more normalized)
I understand your case. You must to have a FOREIGN KEY mapped to a UNIQUE KEY. However, at least I can remember, Yii doesn’t handle it (The core just maintains PK and FK references).
I don’t know exactly how difficult could it be to implement it, but it is, for sure, a thing to think about, since you can have FK ==> UK.