Marius Illmann
Marius Illmann

Reputation: 352

How should I name my columns in my SQL database?

When I create a Database and I need a column with a name like "to settings", what is the best practice? Normally, I write variable in camel-case, but I'm not sure.

to_settings or toSettings

Upvotes: 1

Views: 4167

Answers (4)

Usagi Miyamoto
Usagi Miyamoto

Reputation: 6289

Note that, as SQL convert all identifiers to a standard case (UPPER CASE in the SQL standard, but lower case EG PostgreSQL), most people prefer the former one.

However when using identifier quotation (usually with double quotes, but in MySQL/MariaDB with backticks) the case is not changed.

Upvotes: 1

xCloudx8
xCloudx8

Reputation: 721

As @JNevill said it's your system so do as you want, but if it's your first time developing a database this link could help you a bit on developing a good database.

A good naming convention and formatting will help all the developers to understand better the DB and table connections.

Have fun!

Upvotes: 1

artemis
artemis

Reputation: 7241

There is no "right" or "wrong" way to name things in your own database. What is important, though, is that you stay consistent.

So if you have one field called to_settings, you should continue to use all lowercase, underscored names as opposed to later switching to somethingLikeThis.

Here is an interesting blog post which highlights that underscores are typically common in database applications, but there is a growing desire to begin formalizing and using camelCase or PascalCase as well. https://sqltechblog.com/2016/10/10/making-the-case-for-camelcase-naming/

Upvotes: 2

Milenko Jevremovic
Milenko Jevremovic

Reputation: 1046

I prefer lower case always, like

to_settings

Check this blog https://www.xaprb.com/blog/2008/10/26/the-power-of-a-good-sql-naming-convention/

Upvotes: 5

Related Questions