数据库字符编码设置为utf8mb4,为什么用utf8mb4呢?

1、为什么会有UTF8MB4?

可以简单的理解 utf8mb4 是目前最大的一个字符编码,支持任意文字.

低版本的MySQL支持的utf8编码,最大字符长度为 3 字节,如果遇到 4 字节的字符就会出现错误了。3个字节的 UTF-8 最大能编码的Unicode字符是 0xFFFF,也就是Unicode中的基本多文平面(BMP)。也就是说,任何不在基本多文平面的Unicode字符,都无法使用MySQL原有的 utf8 字符集存储。这些不在BMP中的字符包括哪些呢?最常见的就是Emoji 表情(Emoji 是一种特殊的 Unicode 编码,常见于 ios 和 android 手机上),和一些不常用的汉字,以及任何新增的 Unicode 字符等等。

理论上将,UTF-8 格式使用一至六个字节,最大能编码 31 位字符。最新的 UTF-8 规范只使用一到四个字节,最大能编码21位,正好能够表示所有的 17个 Unicode 平面。而utf8 则是 Mysql 早期版本中支持的一种字符集,只支持最长三个字节的 UTF-8字符,也就是 Unicode 中的基本多文本平面。这可能是因为在MySQL发布初期,基本多文种平面之外的字符确实很少用到。而在MySQL5.5.3版本后,要在 Mysql 中保存 4 字节长度的 UTF-8 字符,就可以使用 utf8mb4 字符集了。例如可以用utf8mb4字符编码直接存储emoj表情,而不是存表情的替换字符。

为了获取更好的兼容性,应该总是使用 utf8mb4 而非 utf8,事实上,最新版的phpmyadmin默认字符集就是utf8mb4。诚然,对于 CHAR 类型数据,使用utf8mb4 存储会多消耗一些空间。

那么utf8mb4比utf8多了什么的呢?多了emoji编码支持.如果实际用途上来看,可以给要用到emoji的库或者说表,设置utf8mb4.

建议普通表使用utf8 如果这个表需要支持emoji就使用utf8mb4

2、新建mysql库或者表的时候还有一个排序规则

utf8_unicode_ci比较准确,utf8_general_ci速度比较快。通常情况下utf8_unicode_ci的准确性就够我们用的了,在我看过很多程序源码后,发现它们大多数也用的是utf8_general_ci,所以新建数据 库时一般选用utf8_general_ci就可以了,如果是utf8mb4那么对应的就是 utf8mb4_general_ci utf8mb4_unicode_ci

原文链接

1、商品表

create table `product_info` (

`product_id` varchar(32) not null,

`product_name` varchar(64) not null comment '商品名称',

`product_price` decimal(8,2) not null comment '单价',

`product_stock` int not null comment '库存',

`product_description` varchar(64) comment '描述',

`product_icon` varchar(512) comment '小图',

`category_type` int not null comment '类目编号',

`create_time` timestamp not null default current_timestamp comment '创建时间',

`update_time` timestamp not null default current_timestamp on update current_timestamp

comment '修改时间',

primary key (`product_id`)

) comment '商品表';

如果订单量太大,product_id不适合自增,无法存储

涉及到财务计算的一般用decimal(8,2)

2、类目表

create table `product_category` (

`category_id` int not null auto_increment,

`category_name` varchar(64) not null comment '类目名字',

`category_type` int not null comment '类目编号',

`create_time` timestamp not null default current_timestamp comment '创建时间',

`update_time` timestamp not null default current_timestamp on update current_timestamp

comment '修改时间',

primary key (`category_id`),

unique key `uqe_category_type` (`category_type`)

)comment '类目表';

3、订单表

create table `order_master` (

`order_id` varchar(32) not null,

`buyer_name` varchar(32) not null comment '买家名字',

`buyer_phone` varchar(32) not null comment '买家电话',

`buyer_address` varchar(128) not null comment '买家地址',

`buyer_openid` varchar(64) not null comment '买家微信openid',

`order_amount` decimal(8,2) not null comment '订单总金额',

`order_status` tinyint(3) not null default '0' comment '订单状态,默认0新下单',

`pay_status` tinyint(3) not null default '0' comment '支付状态,默认0未支付',

`create_time` timestamp not null default current_timestamp comment '创建时间',

`update_time` timestamp not null default current_timestamp on update current_timestamp

comment '修改时间',

primary key (`order_id`),

key `idx_buyer_openid` (`buyer_openid`)

)comment '订单表';

4、订单详情表

create table `order_detail` (

`detail_id` varchar(32) not null,

`order_id` varchar(32) not null,

`product_id` varchar(32) not null,

`product_name` varchar(64) not null comment '商品名称',

`product_price` decimal(8,2) not null comment '商品价格',

`product_quantity` int not null comment '商品数量',

`product_icon` varchar(512) comment '商品小图',

`create_time` timestamp not null default current_timestamp comment '创建时间',

`update_time` timestamp not null default current_timestamp on update current_timestamp

comment '修改时间',

primary key (`detail_id`),

key `idx_order_id` (`order_id`)

) comment '订单详情表';

智能点餐mysql框架图_SpringBoot微信点餐系统--P3数据库设计相关推荐

  1. 1、微信点餐系统之数据库设计

    1.微信点餐系统之数据库设计 ---- ----商品表格 ---- CREATE TABLE `product_info` (`product_id` VARCHAR(32) NOT NULL COM ...

  2. MySQL数据库设计作业 ——《网上书店系统》数据库设计实验报告

    数据库设计作业--<网上书店系统>数据库设计 一.功能需求 普通用户:可以进行最基础的登陆操作,可浏览图书.按类别查询图书.查看 图书的详细信息,还可以注册成为会员. 会员:需要填写详细信 ...

  3. 手机点餐系统概述_廖师兄 微信点餐系统 springcloud学习笔记

    概要:基于netflix的springcloud搭建微信点餐系统 目录 第一部分 项目概要 1.项目环境信息 2.介绍 第二部分 搭建Eureka Server 1.配置Eureka 的applica ...

  4. 第63天学习打卡(MySQL 测试索引 索引原则 数据管理和备份 规范数据库设计)

    7.2测试索引 CREATE TABLE `app_user` ( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(5 ...

  5. mysql 客房_mysql – 酒店客房预订系统的数据库设计

    简介和系统描述 我目前正在酒店设计一个房间预订系统数据库. 客户填写表格/申请表,其中包含以下有关房间的信息: >房间里的人数 >房间的评级 >入住和退房日期 管理员有一个仪表板,其 ...

  6. mysql中图书编号类型_练习1答案-数据库设计

    练习1 数据库设计 学号:,姓名,班级 [实训目的] 1.掌握数据库的基本概念 2.了解数据库设计的基本步骤 3.掌握利用E-R图描述数据库的概念模型的方法 [实训内容] 1.某大学要开发一个选课管理 ...

  7. 考试系统mysql数据库设计_驾校理论考试系统之数据库设计一

    应用开发工具:Microsoft Visual Studio 2010 旗舰版 - 简体中文 sp1-- Microsoft Visual C# 2010 应用程序:文档处理:Microsoft Of ...

  8. 用Mysql做个人信息管理系统_个人信息管理系统数据库设计精选.doc

    个人信息管理系统数据库设计精选 河海大学计算机及信息工程学院(常州) 数据库课程设计 学年学期 2012第二学期 项目名称 个人信息管理 项目组员 曹清云.陈天昊 指导教师 景雪琴 组号:8 目 录 ...

  9. 智能排班系统 【数据库设计】

    文章目录 数据库设计规范 ER图 物理模型 数据表 登录日志表 操作日志表 菜单表 角色表 企业表 门店表 省市区表 门店节日表 消息表 职位表 排班规则表 排班任务表 排班结果存储 scheduli ...

  10. 开源项目工时系统_SpringBoot 微信点餐开源系统!综合运用项目,值得一看!

    作者:Tommmmm来源:www.jianshu.com/p/ae14101989f2 架构 前后端分离: Nginx 与 Tomcat 的关系在这篇文章,几分钟可以快速了解: https://www ...

最新文章

  1. Vijos P1756 数字反转【进制】
  2. 微型计算机实验代码,微型计算机原理实验1-数据传送
  3. linux 解压安卓kernel,android kernel | 环境搭建 + 第一次尝试
  4. 微信回应朋友圈广告无法一键关闭:将持续优化产品体验
  5. [sublime] sublime 实现Markdown编辑器
  6. GDataDate 的本地时间转换
  7. HBase权威指南【中文版】
  8. 编译原理第一章笔记--绪论
  9. 【平面设计】ACDSee 10.0 软件安装教程
  10. Python学习13 ----Seaborn调色板
  11. 遗传算法之扇贝的进化(python代码实现)
  12. 《论文阅读》Multi-Task Learning of Generation and Classification for Emotion-Aware Dialogue Response Gener
  13. 匈牙利命名法(指导)
  14. 机房动力环境集中监控系统
  15. ssm学生请假管理小程序
  16. DS_SpanningTree
  17. postman中文设置以及Test断言设置总结
  18. Java实现 LeetCode 233 数字 1 的个数
  19. 老友逢共话区块链落地,杭州首个区块链周首日精彩瞬间
  20. 中国男足为什么总是输?

热门文章

  1. springboot tmp目录生成机制
  2. 机器学习笔记(八):强化学习
  3. 安卓手机远程连接linux系统,电脑(Linux/Windows)使用SSH远程登录安卓(Android)手机实现无线传输和管理文件(图文详解)-Go语言中文社区...
  4. 资产证券化:国际借鉴与中国实践案例 读后感
  5. 元宇宙区块链卡牌游戏Defina Finance上线|详解
  6. 移动端切图内容包括什么_移动端切图备忘
  7. python数列求和_Python 数字求和
  8. window10 无法使用内置管理员账户打开sticky notes 解决方法
  9. 欧几里得(Euclid)算法的Python实现
  10. android 如何绕过签名校验