Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Singular or plural database table names? [duplicate]

Exact Duplicate

Table Naming Dilemma: Singular vs. Plural Names

Is it better to use singular or plural database table names ? Is there an accepted standard ?

I've heard arguments for and against it, what do you guys think ?

like image 959
lalala2007 Avatar asked Apr 30 '09 20:04

lalala2007


People also ask

Can entity name be plural?

Once instantiated, the name reflects its instance. So with databases, the entity when made into a table (a collection of entities or records) is plural.

Is database plural or singular?

The plural form of database is databases.

Should table name be plural or singular laravel?

In laravel the table names are plural by default and "id" is the default primary key. The pivot table is "derived from the alphabetical order of the related model names". So in your example it would be role_user, not user_role. Last updated 3 months ago.

Should class names be singular or plural?

Definitely singular. You don't create an object of People , you create a collection of Person objects. The only time I would use plurals would be for static classes, i.e. SupportServices , StringUtils , etc. However in this case, the class acts more as a namespace than anything else.


2 Answers

Singular, so you can have:

  • Customer
  • CustomerAddress
  • CustomerAddressAuditTrail

etc.

like image 84
Tim Robinson Avatar answered Sep 23 '22 09:09

Tim Robinson


IMHO, Table names should be plural like Customers.

Class names should be singular like Customer if it maps to a row in Customers table.

like image 28
Gulzar Nazim Avatar answered Sep 24 '22 09:09

Gulzar Nazim