日期:2014-05-16 浏览次数:21035 次
数据库设计中用到binary类型,会将sha1和permission code的值用binary类型表示(sha1 可以是char(40),但是作为索引效率不高)。
permission code是字节的每个位代表一个permission。
?
?
(e.g.: AppInfo & PermissionMap
Sha1 = 0A2976C272F81049B899B3C1EC0260A34477AD4B
permissionCode = 1330526069999549579810939684362649600
==1329227995784915872903807060280344576 | 1298074214633706907132624082305024
== (1 << 120) | (1 << 110)
?
(While, if you call our db interface to access database, you may just pass parameters as Sha1 = ‘0A2976C272F81049B899B3C1EC0260A34477AD4B’
permissionCode = 1330526069999549579810939684362649600
)
?????????????? ???????????????
Sha1 = 53ED7D718E9053086D31FCD329BA56E58236F4A2):
mysql> describe AppInfo;
+----------------+----------------+------+-----+----------------------+-------+
| Field? ???????????| Type?????????? | Null | Key | Default????????????? | Extra |
+----------------+----------------+------+-----+----------------------+-------+
| Sha1????????? ???????????????????????? ? | binary(20) ???? | NO?? | PRI |????????????????????? |?????? |
| PkgName??????? ???????????????? | varchar(1024)? | YES? |???? | NULL???????????????? |?????? |
?
| PermissionCode ?????????? | varbinary(256) | YES? |???? | NULL???????????????? |?????? |
+----------------+----------------+------+-----+----------------------+-------+
?
mysql> describe PermissionMap;
+------------+----------------+------+-----+---------+-------+
| Field????? | Type?????????? | Null | Key | Default | Extra |
+------------+----------------+------+-----+---------+-------+
| id???????? ??????????????? | varbinary(256) | NO?? | PRI | NULL??? |?????? |