常用字典表设计

数据库字典表设计,支撑多层字典表。

CREATE TABLE `sys_dict` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `pid` int(11) DEFAULT '0' COMMENT ' 父ID ',
  `dataType` varchar(50) NOT NULL COMMENT ' 数据类别,首字母大写 ',
  `dataCode` varchar(50) NOT NULL COMMENT ' 数据编码 ',
  `dataValue` varchar(200) NOT NULL COMMENT ' 数据名称/值 ',
  `sortNo` int(11) unsigned DEFAULT '1' COMMENT ' 顺序 ',
  `status` tinyint(2) DEFAULT '0' COMMENT '0正常,1删除',
  `isFixed` tinyint(2) DEFAULT '0' COMMENT '0默认为不固定,1固定',
  `dataDesc` varchar(400) DEFAULT NULL COMMENT '数据描述',
  `updateTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `SYS_DICT_PK` (`id`),
  KEY `idx_dc_dt` (`dataType`,`dataCode`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='系统字典表';
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在 Java 中,可以使用 Map 接口来实现字典设计。Map 接口提供了 key-value 对的存储和访问方式,其中 key 字典中的关键字,value 示与关键字相关联的值。常用的 Map 实现类有 HashMap、TreeMap、LinkedHashMap 等。 下面是一个简单的例子,演示如何使用 HashMap 实现字典: ```java import java.util.HashMap; import java.util.Map; public class Dictionary { private Map<String, String> map; public Dictionary() { map = new HashMap<>(); } public void addEntry(String key, String value) { map.put(key, value); } public String getEntry(String key) { return map.get(key); } public void removeEntry(String key) { map.remove(key); } public boolean containsKey(String key) { return map.containsKey(key); } public static void main(String[] args) { Dictionary dict = new Dictionary(); dict.addEntry("apple", "a round fruit with red or green skin and a white inside"); dict.addEntry("banana", "a curved fruit with a yellow skin"); dict.addEntry("cherry", "a small, round fruit with a red or black skin and a hard seed inside"); System.out.println(dict.getEntry("apple")); System.out.println(dict.containsKey("pear")); dict.removeEntry("banana"); System.out.println(dict.containsKey("banana")); } } ``` 在上面的代码中,我们创建了一个 Dictionary 类,包含了 addEntry、getEntry、removeEntry 和 containsKey 等方法,分别用于添加、获取、删除和判断字典中是否包含某个关键字。在 main 方法中,我们向字典中添加了若干条词条,并测试了各种方法的效果。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值