当前位置:网站首页>集群聊天服务器:数据库表的设计
集群聊天服务器:数据库表的设计
2022-07-23 21:17: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 */;
边栏推荐
- Jianzhi offer II 115. reconstruction sequence: topological sorting construction problem
- [cloud co creation] what magical features have you encountered when writing SQL every day?
- 高数下|三重积分的计算1|高数叔|手写笔记
- "Pulse" to the future! Huawei cloud Mrs helps smooth migration to the cloud
- ES6特性:Promise(自定义封装)
- 2022-7-23 12点 程序爱生活 小时线顶背离出现,保持下跌趋势,等待反弹信号出现。
- 大三实习生,字节跳动面经分享,已拿Offer
- Broadcast (broadcast)
- 1061 Dating
- Major optimization of openim - Message loading on demand, consistent cache, uniapp Publishing
猜你喜欢
随机推荐
Unity solves that animation is not available: the animationclip 'xxx' used by the animation component 'xxx' must be marked as legacy
1062 Talent and Virtue
Visual slam learning | basic chapter 01
(note) learning rate setting of optimizer Adam
第三届SLAM技术论坛-吴毅红教授
【创建 Birthday Card 应用】
[Yunxiang book club No. 13] Chapter V ffmpeg common methods for viewing media information and processing audio and video files
WinDbg实践--入门篇
Identify some positions in the parenthesis sequence
[attack and defense world web] difficulty four-star 12 point advanced question: flatscience
STM32c8t6驱动激光雷达(一)
scala编程(中级进阶实验应用)
LeetCode_ 376_ Wobble sequence
手机股票开户安全吗?
Unity—3D数学-Vector3
Minimum spanning tree: Kruskal
[shader realizes roundwave circular ripple effect _shader effect Chapter 6]
OpenCV图像处理——拉普拉斯金字塔
【攻防世界WEB】难度四星12分进阶题:Confusion1
高数下|三重积分的计算1|高数叔|手写笔记








