快速开发之数据字典设计

快速开发之数据字典设计

  在系统开发中,我们需要使用很多的类别、常用的下拉框等等静态数据,这些静态数据我们可以把它们写入到数据库的一张表中,通过这张表,我们维护它们之间的关系以及信息。

 例如:性别、菜单项、下拉框常量等等静态数据

字段名称数据类型长度约束默认值备注
idint10pkauto_increment主键字段
parent_idint10 null父类id,如果是父类,则为null
typevarchcar(128)128NN 类型名称
dict_codevarchar(128)128NN 字典code值,使用因为或者数字
dict_valuevarchar(4000)4000NN 字典Value值,英文或者中文
order_valueint10  排序字段

 

MYSQL SQL脚本:

create table s_data_dict(
id int(10) primary key auto_increment,
parent_id int(10),
dict_type varchar(128) not null,
dict_code varchar(128) not null,
dict_value varchar(4000) not null,
order_value int(10)
)engine=innodb default charset utf8;

 

Oracle SQL脚本:

create table s_data_dict(
id number(10) primary key,
parent_id number(10),
dict_type varchar2(128) not null,
dict_code varchar2(128) not null,
dict_value varchar2(4000) not null,
order_value number(10)
);

 

实体类:

/**
 * 
 * 类名称:DataDict
 * 类描述:数据字典实体类
 * 创建人:king-pan
 * 修改时间:2014年12月25日
 * @version 1.0
 * 
 */
public class DataDict implements Serializable {
	private static final long serialVersionUID = 1677559039719764920L;
	/**
	 * 主键字段
	 */
	private Integer id;
	/**
	 * 父类ID
	 */
	private Integer parentId;
	/**
	 * 类型
	 */
	private String type;
	/**
	 * 字典code
	 */
	private String dictCode;
	/**
	 * 字典值
	 */
	private String dictValue;
	/**
	 * 排序字段
	 */
	private Integer orderValue;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getOrderValue() {
		return orderValue;
	}
	public void setOrderValue(Integer orderValue) {
		this.orderValue = orderValue;
	}
	public Integer getParentId() {
		return parentId;
	}
	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getDictCode() {
		return dictCode;
	}
	public void setDictCode(String dictCode) {
		this.dictCode = dictCode;
	}
	public String getDictValue() {
		return dictValue;
	}
	public void setDictValue(String dictValue) {
		this.dictValue = dictValue;
	}
	@Override
	public String toString() {
		return "DataDict [id=" + id + ", parentId=" + parentId + ", type="
				+ type + ", dictCode=" + dictCode + ", dictValue=" + dictValue
				+ ", orderValue=" + orderValue + "]";
	}
}

 

转载于:https://my.oschina.net/KingPan/blog/361619

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值