当前位置:网站首页>集群聊天服務器:數據庫錶的設計
集群聊天服務器:數據庫錶的設計
2022-07-23 21:18:00 【_索倫】
MySQL的安裝
本項目是在ubuntu下,需要安裝mysql-server和mysql開發包,包括mysql頭文件和動態庫文件,命令如下:
sudo apt-get install mysql-server =》 安裝最新版MySQL服務器
sudo apt-get install libmysqlclient-dev =》 安裝開發包
修改錶的字符編碼:alter table user default character set utf8;
修改屬性的字符編碼:alter table user modify column name varchar(50) character set utf8;
錶的設計





錶的設計 脚本
-- MySQL dump 10.13 Distrib 5.7.31, for Linux (x86_64)
--
-- Host: localhost Database: chat
-- ------------------------------------------------------
-- Server version 5.7.31
/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @[email protected]@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `allgroup`
--
DROP TABLE IF EXISTS `allgroup`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `allgroup` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`groupname` varchar(50) CHARACTER SET utf8 NOT NULL,
`groupdesc` varchar(200) CHARACTER SET utf8 DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `groupname` (`groupname`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `allgroup`
--
LOCK TABLES `allgroup` WRITE;
/*!40000 ALTER TABLE `allgroup` DISABLE KEYS */;
INSERT INTO `allgroup` VALUES (1,'C++ chat project','start develop a chat project');
/*!40000 ALTER TABLE `allgroup` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `friend`
--
DROP TABLE IF EXISTS `friend`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `friend` (
`userid` int(11) NOT NULL,
`friendid` int(11) NOT NULL,
KEY `userid` (`userid`,`friendid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `friend`
--
LOCK TABLES `friend` WRITE;
/*!40000 ALTER TABLE `friend` DISABLE KEYS */;
INSERT INTO `friend` VALUES (13,15),(13,21),(21,13),(21,15);
/*!40000 ALTER TABLE `friend` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `groupuser`
--
DROP TABLE IF EXISTS `groupuser`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `groupuser` (
`groupid` int(11) NOT NULL,
`userid` int(11) NOT NULL,
`grouprole` enum('creator','normal') CHARACTER SET utf8 DEFAULT NULL,
KEY `groupid` (`groupid`,`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `groupuser`
--
LOCK TABLES `groupuser` WRITE;
/*!40000 ALTER TABLE `groupuser` DISABLE KEYS */;
INSERT INTO `groupuser` VALUES (1,13,'creator'),(1,21,'normal'),(1,19,'normal');
/*!40000 ALTER TABLE `groupuser` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `offlinemessage`
--
DROP TABLE IF EXISTS `offlinemessage`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `offlinemessage` (
`userid` int(11) NOT NULL,
`message` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `offlinemessage`
--
LOCK TABLES `offlinemessage` WRITE;
/*!40000 ALTER TABLE `offlinemessage` DISABLE KEYS */;
INSERT INTO `offlinemessage` VALUES (19,'{
\"groupid\":1,\"id\":21,\"msg\":\"hello\",\"msgid\":10,\"name\":\"gao yang\",\"time\":\"2020-02-22 00:43:59\"}'),(19,'{
\"groupid\":1,\"id\":21,\"msg\":\"helo!!!\",\"msgid\":10,\"name\":\"gao yang\",\"time\":\"2020-02-22 22:43:21\"}'),(19,'{
\"groupid\":1,\"id\":13,\"msg\":\"hahahahaha\",\"msgid\":10,\"name\":\"zhang san\",\"time\":\"2020-02-22 22:59:56\"}'),(19,'{
\"groupid\":1,\"id\":13,\"msg\":\"hahahahaha\",\"msgid\":10,\"name\":\"zhang san\",\"time\":\"2020-02-23 17:59:26\"}'),(19,'{
\"groupid\":1,\"id\":21,\"msg\":\"wowowowowow\",\"msgid\":10,\"name\":\"gao yang\",\"time\":\"2020-02-23 17:59:34\"}');
/*!40000 ALTER TABLE `offlinemessage` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`password` varchar(50) DEFAULT NULL,
`state` enum('online','offline') CHARACTER SET utf8 DEFAULT 'offline',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user`
--
LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (13,'zhang san','123456','online'),(15,'li si','666666','offline'),(16,'liu shuo','123456','offline'),(18,'wu yang','123456','offline'),(19,'pi pi','123456','offline'),(21,'gao yang','123456','offline');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET [email protected]_TIME_ZONE */;
/*!40101 SET [email protected]_SQL_MODE */;
/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */;
/*!40014 SET [email protected]_UNIQUE_CHECKS */;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;
/*!40111 SET [email protected]_SQL_NOTES */;
边栏推荐
- Failed to introspect Class FeignClientFactoryBean 异常排查
- How to get the worker's hat? Where is the worker's helmet?
- Microservice architecture vs single service architecture [what can Huawei cloud service do in the microservice mode]
- Edge cloud | 1. overview
- 如何在面试中介绍自己的项目经验
- Flink principle and development summary (detailed)
- Jetson nano烧录踩坑记(一定可以解决你的问题)
- 分布式能源的不确定性——风速测试(Matlab代码实现)
- At 12 o'clock on July 23, 2022, the deviation from the top of the line of love life hour appeared, maintaining a downward trend and waiting for the rebound signal.
- 【持续更新】树莓派启动与故障系列集锦
猜你喜欢

【持续更新】树莓派启动与故障系列集锦

Qt桌面白板工具其一(解决曲线不平滑的问题——贝塞尔曲线)

手机测试相关基础知识

Typescript Basics

Leetcode hot topic hot52-100

221. Largest square ● &1277. Square submatrix with statistics all 1 ● ●
![[wechat applet] do you know about applet development?](/img/3d/da58255aeb6bf6bc5021d988906bcc.png)
[wechat applet] do you know about applet development?

【愚公系列】2022年06月 .NET架构班 084-微服务专题 Abp vNext微服务通信

【创建 Birthday Card 应用】

WinDbg实践--入门篇
随机推荐
比较关注证券公司究竟哪个佣金最低?请问网上开户安全么?
Vite3 learning records
Broadcast (broadcast)
UnauthorizedAccessException:Access to the path “/xx/xx.xx“ is denied
第三届SLAM技术论坛-吴毅红教授
Proof of green Tao theorem (1): preparation, notation and Gowers norm
Qt桌面白板工具其一(解决曲线不平滑的问题——贝塞尔曲线)
分布式能源的不确定性——风速测试(Matlab代码实现)
如何在面试中介绍自己的项目经验
【攻防世界WEB】难度四星12分进阶题:FlatScience
Minimum spanning tree: prim
1063 Set Similarity
Boost Filesystem使用手册
High numbers | calculation of triple integral 2 | high numbers | handwritten notes
TCP half connection queue and full connection queue (the most complete in History)
Junior intern, ByteDance, after sharing, has been offered
2022.7.22 js对象
When we talk about Chen Chunhua and Huawei, what are we talking about?
《迷失》stray工人帽子获得方法 工人安全帽在哪里?
确定括号序列中的一些位置