Database Disrespect & MySQL Solutions

In my opinion, there’s a lack of respect for databases in the development community.  I will present two data points to prove my point, including a MySQL example.

Data Point One

I first went to grad school at Washington State University in the early 80’s.  When it came time to pick a Master’s Thesis, I was told, and I quote: “Thy shalt not do your Master’s Thesis on database.”  “Database is a dead, full proved, subject.”

Tell that to Oracle.  Funny how I now work for Oracle. And my PhD thesis is in the area of database.

Data Point Two

The following is a common engineering problem:

  • Given two user processes that need to pass data to each other.
  • Design the data passing mechanism.

I am amazed at how many times the following solution is chosen:

  • The processes will use a data file in the ufs file system (commonly  under /tmp).
  • The data file will contain key/value pairs.
  • For example: HOME=/home/eng.

So what are the problems with this solution?

  1. What happens if the data file gets corrupted?   If the data file gets corrupted somehow, the file has to be sanity checked, and then if corrupted, restored to a previously known good state. This procedure needs to be performed every time the system is booted.
  2. What happens if a process crashes during an update of the data file?  Then the file could become corrupted and we have to deal with the previous problem. How easy is it to change the syntax of the data file?  We have to create a syntax that both processes agree on and then change both processes.

I have a much better solution to all of the above. Use a simple database (like MySQL).  How does a simple database solve all these issues?

  • MySQL allows you set the database table type to InnoDB.  This table type ensures that tables are sanity checked when they are read.
  • This InnoDB table type also ensures that transactions are guaranteed to be safe.  That is, the transaction is 100% complete or nothing at all.
  • Adding columns to a table is trivial. MySQL supports the richness of SQL.

So in conclusion, how about we stop recreating the wheel and start taking advantage of the power of the database.