SQL: Advantages of an ENUM vs. a one-to-many relationship?

后端 未结 7 2281
独厮守ぢ
独厮守ぢ 2021-02-07 04:14

I very rarely see ENUM datatypes used in the wild; a developer almost always just uses a secondary table that looks like this:

CREATE TABLE officer_ranks (
id in         


        
7条回答
  •  清歌不尽
    2021-02-07 04:59

    Well, you don't see, because usually developers are using enums in programming languages such as Java, and the don't have their counterparts in database design.

    In database such enums are usually text or integer fields, with no constraints. Database enums will not be translated into Java/C#/etc. enums, so the developers see no gain in this.

    There are very many very good database features which are rarely used because most ORM tools are too primitive to support them.

提交回复
热议问题