Persisting Enums in database tables

后端 未结 5 1292
攒了一身酷
攒了一身酷 2021-01-11 09:43

I have an order which has a status (which in code is an Enum). The question is how to persist this. I could:

  1. Persist the string in a field and then map back t
5条回答
  •  星月不相逢
    2021-01-11 10:20

    #3 is the most "proper" from a database/normalization standpoint. Your status is, in effect, a domain entity that's linked to the order entity.

提交回复
热议问题