Allow me to suggest a few database best practices:
- Use enforced referential constraints in your relational databases
- Write your code to avoid calculations on columns in the WHERE and ON clauses
- Do not enable auto-shrink on the database
There are lots of other best practices I could recommend, but we’ll go with these three. To my mind, these are reasonable statements, and I’m making them based on years of experience, knowledge, study, and the advice of experts that I trust (due to their years of experience and knowledge). However, you’ll find that not everyone can agree. Further, some people have decided that, for example, foreign key constraints slow down development, so we’re tossing them. Others that we can’t afford to buy a disk, and keeping the databases shrunk is vital, so we’ll let them shrink every chance we get. I’ve literally heard the statement “Who are you to tell me different?” when it comes to best practices.
Short answer: Nobody. But I’m Still Right.
Let’s look at something related, but utterly different: Band Plans.
I’ve been working with Ham radios for about year since I got my Technician’s license. I’m actively studying for my General license (and will probably pass the test before this gets published). While the licensing is through the United States government by way of the Federal Communications Commission (FCC), that’s as far as government involvement goes. Volunteers manage the rest of Ham radio within the US.
While the radio waves can appear to be quite vast, they are a limited resource. To better manage this resource, the Ham radio volunteers have established several best practices. The best practices I’m referring to at the moment are the Band Plans. These define what kinds of radio signals you can send within the spectrum — Upper Side Band above 10mhz and Lower Side Band below. Phone (voice) only between 24.93mhz and 24.99mhz, but RTTY (don’t ask) and data only between 24.89mhz and 24.93mhz. The FCC enforces none of these. These are all volunteer defined best practices to which a good Ham operator adheres. However, be sure, the other Ham operators will point out when you’re violating the Band Plans. The best practices, despite not being hard and fast laws with punishment meted out by the government are still managed.
Could I decide that, instead of following the band plan, I’m going to transmit via phone (talking) way down in the data segment between 24.89mhz and 24.93mhz? Yes. Unfortunately, since no one will be looking for phone communications down there, it’s going to be awfully lonely until I step on someone’s data signal and I get an education from my fellow Hams.
Frankly, the best practices for databases should be equally well enforced. Yeah, sometimes, someone is going to make up a silly “best practice” that really shouldn’t be one (I’m old enough to remember when I was told that anything more than three joins was against best practices. It was silly 25 years ago, and it’s silly now). However, most of what is defined as best practices are good guidelines for the majority of your operations. In a true emergency, can I transmit pretty much anywhere I please? You bet. In a real emergency, can you violate any of these best practices? Absolutely. However, is this a true emergency, or are you just unwilling to realize that, maybe your development practices are to blame, not foreign key enforcement? I’m able and willing to support any violation of best practices you’re willing to show me, but you have to back it up with valid reasons, not just because it was an easy, short term choice. We data professionals should define our Band Plans and help everyone to operate within them.