How not to design a database.

Jorge Castro
Cook php
Published in
2 min readDec 13, 2018

I work in education/consulting and it is one of the example of what I have seen (during this year only). And, I’m not talking about small fries but companies with LOTS of digits. I said: Oh, this data it’s wrong, it shows $xxxxxxx and they tell me, yes, the information is right.

Database’s mistakes

  • Tables with a prefix to say that it is a table, example TABLE_CUSTOMER or TBL_CUSTOMER. (ed: Sheesh, I know that it’s a table!.)
  • Cryptic tables, TBL23. (ed: WTF?. SAP, I am watching you.)
  • Using the tables as non relational, (you will get a cookie if you can find the mistake):
  • Varchar as index (ed: it is extra heretical)
  • Inconsistent table. (ed: However, LEFT JOIN saves the day. Pro-tip: FOREIGN-KEY is your friend, your pal, your cuate!.)
  • Pasword in plain text. (ed: even md5 is way better)
  • Installing Oracle by following the Database Administrator’s Guide
  • Age as a integer. (ed: now()-datefield() will do the damn trick!)
  • Or, Age as a varchar
  • Column with varchar with padding for space. Because char is for cowards!
  • Date column as varchar.
  • Using nchar and nvarchar for everything.
  • Float instead of money. Why? because the architect says that float is more efficient. (tips: extra heretical too)
  • Blob
  • More blob. Database loves blob so much.
  • Using Trigger for reporting. (ed: please, don’t ask)
  • Trust me, you could do 2 inserts without transition. What could go wrong?.
  • MyISAM because it’s the fastest. (ed: lie, Blackhole is the fastest).
  • The Log file is too big, it’s time to delete it manually. Why? Who cares, it is only the log file.
  • No Primary Key?. Why?. Because reasons.
  • A table with 30 columns and 30 indexes.
  • Join without using any index
  • Select to the biggest table of the system without filtering. We need to read 100 million rows to show a 30 lines report!.
  • Oracle is cheaper and you can save money $$$$$ (tips: no, it’s not!)
  • My IBM vendor tells me that IBM is cool.
  • Replication is funny
  • Bokup? what is that?.
  • Replication never fails.
  • Cursor for everything, what could go wrong?.
  • Who needs parametric query?.
  • Varchar(1) for Y/N fields (and no nulls or empty). Why?, because char is for cowards too.
  • My database server needs more CPU, not ram!.
  • We don’t need a new table but more columns. Invoices, who purchase more than 3 products at once?

--

--