Guidelines for good schema design

Comparing #1 with #2

Revision #2 was created by Maurizio Domba Cerin Maurizio Domba Cerin on Aug 27, 2011, 8:26:53 PM.

doc fix

Content

[...]
But even without Yii considering them, foreign-keys are a vital part of maintaining referential integrity of your database; there are many tutorials on the web on how to learn about them.

DO name your foreign key fields ending in "id"
----------------------------------------------
Related to the prior note, if
you have a field that holds the ID of a user, call the field `userid` rather than `user`. This is because for every foreign key you include in a table, you'll almost certainly wish to define a **relation** for it.

In Yii, class variables, db fields, virtual attributes, relations all share a single namespace, so it's not possible to have `$model->user` be **both** the foreign key in the table **and** the relation.

By calling the FK `userid`, the BELONGS_TO relation of `$model->user` forms naturally and easily:
[...]