Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table Naming: Underscore vs Camelcase? namespaces? Singular vs Plural?

I've been reading a couple of questions/answers on StackOverflow trying to find the 'best', or should I say must accepted way, to name tables on a Database.

Most of the developers tend to name the tables depending on the language that requires the database (JAVA, .NET, PHP, etc). However I just feel this isn't right.

The way I've been naming tables till now is doing something like:

doctorsMain doctorsProfiles doctorsPatients patientsMain patientsProfiles patientsAntecedents  

The things I'm concerned are:

  • Legibility
  • Quick identifying of the module the table is from (doctors||patients)
  • Easy to understand, to prevent confusions.

I would like to read any opinions regarding naming conventions. Thank you.

like image 981
MarioRicalde Avatar asked Dec 10 '09 13:12

MarioRicalde


People also ask

Should table names be singular or plural?

So Which Should I Use: Singular or Plural? The correct answer is that there is no right or wrong when naming database tables — just be consistent from the start. The only wrong answer with database table names is to use a combination of plural and singular.

Should SQL table names be singular or plural?

It's a pretty established convention that database table names, in SQL at least, should be singular. SELECT * FROM user; See this question and discussion. It's also a pretty established convention that RESTful API resource names should be plural.

Should I use camelCase in SQL?

There seems to be a tendency towards writing identifiers in lower case, with no agreement on the case of keywords. Also, in most dialects, people prefer snake_case for identifiers, although in SQL Server, people seem to prefer PascalCase or camelCase . That's for style.

Should column names be camelCase?

Column NameYou should use camelCase for your column names, specially for Node.


2 Answers

Being consistent is far more important than what particular scheme you use.

like image 193
David Oneill Avatar answered Sep 25 '22 12:09

David Oneill


I typically use PascalCase and the entities are singular:

DoctorMain DoctorProfile DoctorPatient 

It mimics the naming conventions for classes in my application keeping everything pretty neat, clean, consistent, and easy to understand for everybody.

like image 45
Justin Niessner Avatar answered Sep 23 '22 12:09

Justin Niessner