ZeNstok
ZeNstok

Reputation: 156

What does symfony recommend for database table names?

I have a debate with a co-worker whether we should use singular or plural for database table names (the Doctrine annotations). He suggests singular names, but i find it way more logical to have it in plural names and i was wondering if there is any recommendation from Symfony because i couldn’t find any.

Thoughts?

Upvotes: -1

Views: 4745

Answers (1)

m1n0
m1n0

Reputation: 609

As already mentioned by Alexander Marinov, this is not a Symfony question, Symfony does not have any recommendation for this - this is more of a database design question - and is a duplicate of many questions here on stackoverflow and around the internet as such.

But to give you some ideas, you have several options:

Use singular:
This is most commonly used. If you are concerned that the table name in singular makes no sense think about it this way - the table name represents one record in it, not all of them.

This also makes your code sensible - as already stated by Fabian, you want to create singulars in code.

Use plural:
It might make sense in database, but the entity name and code will be ugly - just think of $car = new Cars();

Use both singular and plural:
Doctrine allows you to specify different table name than entity name using the @Table annotation, but this is not very common practice, again, if you think of the table name as a representation of one record in the table, and not collective name for all records in it, this option does not make much sense.

There is a lot of discussion about this around the internet, look around, get some ideas and then its up to you and your colleague what you agree on.
Some examples:
Table Naming Dilemma: Singular vs. Plural Names
https://medium.com/@fbnlsr/the-table-naming-dilemma-singular-vs-plural-dc260d90aaff

Upvotes: 3

Related Questions