Garet
6 months ago
676
6
Tips

Naming convention for models with relationships

Posted 6 months ago by Garet

Let's say I have a model called Users.

Then I have 2 related models called LoginHistory and Device.

LoginHistory records each login that a user makes, and Device keeps track of different devices/browsers that a user signs in with.

However I can't decide if to instead call my models UserLoginHistory and UserDevice.

Not having the prefix is more intuitive in terms of less typing.

However with the user prefix my models, and in particular the database tables, are grouped together alphabetically, and it's also more obvious at a glance that they're all related to a user.

I know there's no right or wrong answer, but I wondered if there was an overall consensus?

Please sign in or create an account to participate in this conversation.