Tip #11: Use proper naming strategies (i.e., human-readable) for your data.
Humans love to be creative when naming things. Programmers and IT staff take this to a whole new level, oftensearching a popular domain dedicated to Naming Schemes. And while we may love referring to all the items wework with by their Nordic God names, when we expect other people not living in our world to work with it, well,it can become a problem.
Keeping your naming structures human-readable and intuitive is key to getting the most use out of your datasets. Naming your databases, tables and columns obscure names will only cause confusion and sometimeslatency. (We have seen table names that are VERY long -- on the order of 80-100 characters. This is not only apain to look at from a database architecture view but even worse for the poor soul who has to write SQL queriesagainst them.)
So what do you do when you have a creative DBA or you yourself are this DBA with a fixation for non-intuitivenaming?
Remember that ALIAS is your friend.
The SQL ALIAS command is structured as follows:
For Column Level Aliases
SELECT column_name AS alias_name FROM table_name;
For Table Level Aliases
SELECT column_name(s) FROM table_name AS alias_name;
An example will show how changing the column or table name into an intuitive alias can not only shorten yourSQL queries but also make your database more usable for end users.
SELECT eska AS Name, essa AS Home, meena AS Region FROM
OneRingToRuleThemAllLordofTheRingsTrilogy as LOTR WHERE LOTR.Home=”Shire” AND LOTR.
The full text would appear like this without the use of Aliases
SELECT eska, essa, meena FROM OneRingToRuleThemAllLordofTheRingsTrilogy
WHERE OneRingToRuleThemAllLordofTheRingsTrilogy.meena =”Shire” AND
OneRingToRuleThemAllLordofTheRingsTrilogy.eska =”Frodo Baggins”
You can see that column names labeled in Elvish, as well as very long table names, are difficult to type and not easy to grasp quickly. This makes it easy to make mistakes in queries. Using aliases to keep thing short,simple and intuitive will save you many headaches for ourself and your database users down the road.