We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

MySQL FK vs Phalcon virtual FK


I am curious what do you guys recommend in terms of FK (and CASCADE operations, etc).

To use database FK or to use Phalcon virtual FK's.

I think that DB, in any case, must represent some level of logical structure of data and implement Boyce–Codd normal form . In other words DB must ensure the integrity of the structure. Models must ensure the data consistency.

So i use both :)

P.S. Data consistency you may implement in DB, but it's more difficult than in Model.

edited Nov '16

I'm old school, so I always use RDBMS for what it is made for - Forein keys, relations, constraints etc.


I suppose if you create the FK, relations, etc in DB you don't create them also on Phalcon ORM ?