Search Postgresql Archives

Re: enum bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 14, 2016 at 8:52 AM, Joshua D. Drake <jd@xxxxxxxxxxxxxxxxx> wrote:

 If improved enough, maybe we could get to a
point where they could actually be used; otherwise why the heck did we
let the feature in the database in the first place?  I think all these
"use a lookup table, you silly!" answers are missing the point.

1. I thought ENUMS were not needed in the first place. I still do.

2. I never called anyone silly, nor was I derogatory or dismissive. I offered, my solution to this problem because ENUMS are a pain in the butt and have been since the original implementation. I have yet to see a valid reason to use them instead of a lookup table. I have even written articles about the three basic solutions:

https://www.commandprompt.com/blogs/joshua_drake/2009/01/fk_check_enum_or_domain_that_is_the_question/

​The one nice thing about enums is that you get two concepts in one column - a human readable label and a system used ordering.

i.e., "SELECT enum_value FROM tbl ORDER BY enum_value" actually
 
​gives you a meaningful order without having to carry around, or relink to, a lookup table to get an ordering column.

​Now, this is a bit overrated since you immediately lose that ability if you export to a Spreadsheet program, or otherwise lose the ordering nature during a convert-to-text operation.

​David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux