Info ~ travel musings for the masses

I was browsing through the source code of WordPress this evening and noticed that it’s table creation statements used a lot of ENUM declarations for fields that are ‘Y’ or ‘N’. I am not dissing the code in any way but ENUM is not an across the board datatype. It is not in PostgreSQL at all and I believe there is a way to build it into Oracle.

The problem I have is that we (developers) have a huge push towards standards compliance with CSS and RSS so why not databases? I should be able to take code that is intended for MySQL and directly port it to SQL Server, Oracle, PostgreSQL, or Firebird. I shouldn’t have to worry about datatypes or whether sub-queries are allowed (since MySQL 4.1 they’re allowed).

I know what you’re thinking, “But Stephan, MySQL is the most commonly used Open Source database right now” and I agree but my issue is that in some situations MySQL either doesn’t cut it or there are issues with the host, company, etc. that keep MySQL from being installed.

It is not hard to use CHAR(1) to get the same effect as ENUM or SET. The real problem with the SET type is that if you make something like:


technically it is completely valid to have a value in the database with (‘YN’) in the field. It is a dangerous type and I have slowly started removing it from my old code and not using it in new code.

This is not an attack towards Matt or any of the other WordPress developers, just some constructive criticism.


No comments yet.

Leave a Reply

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS