-1

I want to which is, in your opinion, the best practice for name SQL columns. Example: Let's say that i have two columns name referenceTransactionId and source now there is another way to write this like refTxnId and src

which one is the better way and why? Is it because of the memory usage or because of the readability?

  • Does this answer your question? [Best practices for column naming in Sql](https://stackoverflow.com/questions/664017/best-practices-for-column-naming-in-sql) – dns_nx Apr 27 '20 at 11:41

1 Answers1

1

Although this is a matter of opinion, I am going to answer anyway. If you are going to design a new database, write out all the names completely. Why?

  • The name is unambiguous. You'll notice that sites such as Wikipedia spell out complete names, as do standards such as time zones ("America/New_York").
  • Using a standard like the complete name means that users don't have to "think" about what the column might be called.
  • Nowadays, people type much faster than they used to. For those that don't, type ahead and menus provide assistance.
  • Primary keys and foreign keys, to the extent possible, should have the same name. So, I suspect that referenceTransactionId should simply be transactionId if it is referencing the Transactions table.

This comes from the "friction" of using multiple databases and having to figure out what a column name is.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786