枚举或表? [英] Enums or Tables?

查看:177
本文介绍了枚举或表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提出这个社区的wiki,因为我将不胜感激人们的办法,但不一定答案。

I am making this a community wiki, as I would appreciate people's approach and not necessarily an answer.

我在我有很多的查询类型数据字段,不改变的情况。一个例子是:

I am in the situation where I have a lot of lookup type data fields, that do not change. An example would be:

年薪结果
选项:0 - 25K

选项:25K - 100K结果
选项:100K +

Yearly Salary
Option: 0 - 25K
Option: 25K - 100K
Option: 100K +

我想有这些容易获得通过枚举,但选择也想考证可用值在DB,我会做的文本值,而不是一个ID的报告。此外,由于它们是静态的,我不希望让到数据库的调用。

I would like to have these options easily available through an enum, but would also like to textual values available in the DB, as I will do reporting on the textual values and not a ID. Also, since they are static I do not want to be making calls to the DB.

我想在一个枚举和表复制这一点,但想听到一些备用的想法。

I was thinking duplicating this in an enum and table, but would like to hear some alternate thoughts.

感谢

推荐答案

我觉得一个枚举是馊主意。刚刚给你展示的数据类型,它可能会改变。最好能有ID /最小/最大/描述字段的数据基础表时,你的应用程序初始化您加载。

I think an enum is a bad idea. Just given the type of data you show, it's subject to change. Better to have a data base table with ID/Min/Max/Description fields that you load when your app initializes.

这篇关于枚举或表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆