Association tables needed?

Is it common practice in phalcon that association-tables are always used for all types of database relations?

(I understand it is needed for M-M relations. For 1-M relations it could be left out, but I'm not sure if that would break the build-in function to for example retrieve data.)

Hey,

you do not need association tables for 1-M relations. You can read more here: https://docs.phalconphp.com/en/latest/reference/models.html#defining-relationships



671

@Nikolay I read these docs, but it only has examples using association tables. that is why I asked. The docs are not really clear about this.

edited Oct '15

@allox yes in the docs the example covers the 3 table scenario (https://docs.phalconphp.com/en/latest/%5images/eer-1.png)

But you can simply use:

class Categories extends Model
{
    public $id;
    public $name;

    public function initialize()
    {
        $this->hasMany("id", "Products", "category_id");
    }
}

Where Products table has category_id and 1 category has many products.