Support the ongoing development of Laravel.io →
Database Eloquent

Hi Guys,

I have a question about the naming convention of the tables. We have multiple tables with should have the same name. We have a application with news, vacancies, locations etc.

All of those are cannected to a category. What should your database tables look like?

  • One category table with a column that stores the type
  • Tables like newscategories, locationcategories etc.
  • Or something else?!

I think it's important to keep Eloquent and pivot tables in mind in this decision. I'd like to hear your opinion on this.

Last updated 2 years ago.
0

Depends totally on your app. Are those categories relevant to all the models you listed, or every model has its own categories type?

You may use polumorphic relations for this, just as taggable in the docs - be sure to read that http://laravel.com/docs/eloquent#polymorphic-relations

Last updated 2 years ago.
0

The categories are all on their own.

An other example: We have news photos. Both have comments. But there can only be one comments table!

What would you do?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

prodes prodes Joined 27 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.