td 字典表_数据库库设计:字典表的设计详解

在设计软件时,经常会遇到类型的问题,也就是分类问题,例如:员工分类,正式员工,试用员工,实习生。这些数据是设计成字典表还是设计成常量?

在我们的系统中一直是设计成表的,但由于系统中有很多有很多中这种类型,导致很多表只有不到四五条数据,数据几乎不变,为了展示,使用视图,使用表关联。

其实我感觉像这样几乎不变的数据,设计成常量,应该更好,性能好,修改也简单,要改成表也很方便,相反如果是表要改成常量就困难了,尤其是使用了大量视图为了展示。

如果以后为了性能优化,还可以生成js脚本,生成JS对象,加快处理速度。

设计实例

public class EmployeeType

{

public const  int Trial = 0;

public const int Official = 1;

public const int Internship = 2;

///

/// 用于展示

///

///

///

public static  string GetText(int type)

{

string text="";

switch (type)

{

case Trial:

text = "试用";

break;

case Official:

text = "正式";

break;

case Internship:

text = "实习";

break;

default:

text = "未定义";

break;

}

return text;

}

///

/// 用于下拉

///

///

///

public static List GetDropList(int type)

{

List list = new List();

list.Add(new DropListItem()

{

Value = Trial,

Text = GetText(Trial)// "试用"

}

);

list.Add(new DropListItem()

{

Value = Official,

Text = GetText(Official)

}

);

list.Add(new DropListItem()

{

Value = Internship,

Text = GetText(Internship)

}

);

return list;

}

}

public class DropListItem

{

public int Value { set; get; }

public string Text { set; get; }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值