1、用于存储国家、省、市、区/县、镇等地区区域划分信息
设计中使用到了树形结构的相关信息,如parent_id,left_value,right_value。方便后续信息的检索。
对于树形结构在数据库中的存储结构,后续会有相应设计说明。
2、设计相应的E-R图如下:
3、建表语句如下:
drop table canna_base_area;
/*==============================================================*/
/* Table: canna_base_area */
/*==============================================================*/
create table canna_base_area (
id serial8 not null,
code character varying(255) null,
cn_name character varying(255) null,
en_name character varying(255) null,
value character varying(255) null,
status character varying(255) null,
remark character varying(255) null,
sort bigint null,
parent_id bigint not null,
left_value bigint not null,
right_value bigint not null,
type character varying(32) null,
constraint PK_CANNA_BASE_AREA primary key (id)
);
comment on table canna_base_area is
'地区信息表';
comment on column canna_base_area.id is
'ID';
comment on column canna_base_area.code is
'编码';
comment on column canna_base_area.cn_name is
'中文名称';
comment on column canna_base_area.en_name is
'英文名';
comment on column canna_base_area.value is
'地区值';
comment on column canna_base_area.status is
'状态';
comment on column canna_base_area.remark is
'备注';
comment on column canna_base_area.sort is
'排序显示';
comment on column canna_base_area.parent_id is
'父节点编码';
comment on column canna_base_area.left_value is
'左值';
comment on column canna_base_area.right_value is
'右值';
comment on column canna_base_area.type is
'地区类型:国家/省/市';