海运,国家 港口 城市关系表,包含国内和国外(货代)"/>
Mysql设计航线包含空运和海运,国家 港口 城市关系表,包含国内和国外(货代)
航线、港口设计
1.国家城市表
2.航线表
3.港口
4.航线关系表
话不多说直接上代码:
##国家 drop table country;
create table `country` (`pkid` bigint(20) not null auto_increment,`name` varchar(200) default null COMMENT '国家名称',`english_name` varchar(200) default null COMMENT '英文名称',`is_international` tinyint(1) not null default '0' COMMENT '0-国内 1-国外',`valid` tinyint(1) not null default '1' COMMENT '0无效,1有效',`added_time` datetime default CURRENT_TIMESTAMP COMMENT '创建时间',`modified_time` datetime default null on update CURRENT_TIMESTAMP COMMENT '修改时间',primary key (`pkid`) using BTREE
) engine = InnoDB auto_increment = 1 default CHARSET = utf8mb4 COMMENT = '国家';##省 drop table province;
create table `province` (`pkid` bigint(20) not null auto_increment,`code` varchar(100) default null COMMENT '省编码',`name` varchar(150) default null COMMENT '省名称',`english_name` varchar(150) default null COMMENT '英文名称',`country_id` bigint(20) default null COMMENT '国家ID',`added_time` datetime default CURRENT_TIMESTAMP COMMENT '创建时间',`modified_time` datetime default null on update CURRENT_TIMESTAMP COMMENT '修改时间',`valid` tinyint(1) not null default '1' COMMENT '0无效,1有效',primary key (`pkid`) using BTREE,key `idx_country_id` (`country_id`)
) engine = InnoDB auto_increment = 1 default CHARSET = utf8mb4 COMMENT = '省';##城市 drop table city;
create table `city` (`pkid` bigint(20) not null auto_increment,`code` varchar(100) default null COMMENT '市编码',`name` varchar(150) default null COMMENT '市名称',`english_name` varchar(150) default null COMMENT '英文名称',`parent_id` varchar(100) default null COMMENT '省编码',`country_id` bigint(20) default null COMMENT '国家ID',`added_time` datetime default CURRENT_TIMESTAMP COMMENT '创建时间',`modified_time` datetime default null on update CURRENT_TIMESTAMP COMMENT '修改时间',`valid` tinyint(1) not null default '1' COMMENT '0无效,1有效',primary key (`pkid`) using BTREE,key `idx_province_code` (`province_code`),key `idx_country_id` (`country_id`)
) engine = InnoDB auto_increment = 1 default CHARSET = utf8mb4 COMMENT = '城市';##航线 drop table airline;
create table `airline` (`pkid` bigint(20) not null auto_increment,`name` varchar(200) default null COMMENT '航线名称',`english_name` varchar(200) default null COMMENT '英文名称',`country_id` bigint(20) default null COMMENT '国家ID',`type` tinyint(4) not null default '0' COMMENT '0-海运 1-空运',`is_international` tinyint(1) not null default '0' COMMENT '0-国内 1-国外',`sort_code` int(4) default null COMMENT '排序',`valid` tinyint(1) not null default '1' COMMENT '0无效,1有效',`added_time` datetime default CURRENT_TIMESTAMP COMMENT '创建时间',`modified_time` datetime default null on update CURRENT_TIMESTAMP COMMENT '修改时间',primary key (`pkid`) using BTREE,key `idx_country_id` (`country_id`)
) engine = InnoDB auto_increment = 1 default CHARSET = utf8mb4 COMMENT = '航线';##港口 drop table port;
create table `port` (`pkid` bigint(20) not null auto_increment,`name` varchar(200) default null COMMENT '港口名称',`alias` varchar(200) default null COMMENT '港口别名',`english_name` varchar(200) default null COMMENT '港口英文名称',`english_alias` varchar(200) default null COMMENT '港口英文别名',`port_code` varchar(200) default null COMMENT '港口代码',`city_id` bigint(20) default null COMMENT '城市ID',`country_id` bigint(20) default null COMMENT '国家ID',`sort_code` int(4) default null COMMENT '排序',`valid` tinyint(1) not null default '1' COMMENT '0无效,1有效',`added_time` datetime default CURRENT_TIMESTAMP COMMENT '创建时间',`modified_time` datetime default null on update CURRENT_TIMESTAMP COMMENT '修改时间',primary key (`pkid`) using BTREE,key `idx_port_code` (`port_code`),key `idx_country_id` (`country_id`),key `idx_city_id` (`city_id`)
) engine = InnoDB auto_increment = 1 default CHARSET = utf8mb4 COMMENT = '港口';##航线关系表 drop table airline_route;
create table `airline_route` (`pkid` bigint(20) not null auto_increment,`airline_id` bigint(20) default null COMMENT '航线ID',`source_port_id` bigint(20) default null COMMENT '目的港口ID',`destination_port_id` bigint(20) default null COMMENT '目的港口ID',`type` tinyint(4) not null default '1' COMMENT '0-起运港 1-目的港',`sort_code` int(4) default null COMMENT '排序',`added_time` datetime default CURRENT_TIMESTAMP COMMENT '创建时间',`modified_time` datetime default null on update CURRENT_TIMESTAMP COMMENT '修改时间',`valid` tinyint(1) not null default '1' COMMENT '0无效,1有效',primary key (`pkid`) using BTREE,key `idx_airline_id` (`airline_id`),key `idx_source_port_id` (`source_port_id`),key `idx_destination_port_id` (`destination_port_id`)
) engine = InnoDB auto_increment = 1 default CHARSET = utf8mb4 COMMENT = '航线关系表';
更多推荐
Mysql设计航线包含空运和海运,国家 港口 城市关系表,包含国内和国外(货代)
发布评论