基于mysql的bbs设计二
3。数据库设计
关键还是mysql的效率问题,合理分配mysql的内存,特别是table cache的
大小。另外,当系统突然掉电呢?mysql是否robust?
table的名字设计,采用一位前缀表明类型,全部用小写表示(?),例如:
系统的数据库,以s为前导,如用户表:suser(sUSER 呢?),具体如下:
s :系统表,suser,sclass
m :用户信件表,msysop,mdrangon
w :用户消息表,wsysop,wdrangon
a :版面索引表,alinux,acampus
b :版面文章表,blinux,bcampus
c :特殊分类版面表,cnewboard
i :精华区索引表,ilinux,ilinux01,icampus,icampus04
j :精华区文章表,jlinux,jcampus,
另外,是使用字串还是数字作为标识呢?例如,一个叫sysop的帐号,其
id是1,他的信的表是msysop还是m00001呢?同样,一个叫campus的版,对应的
代码是5,则这个版的文章的表名是bcampus还是b00005呢?可能用字串会容易
理解,查错吧。
用户信息表:suser
usernum int unique, // 唯一标识符,最多30000个帐号,会不会太少了?
userid char[20] primary key, // 排序的关键字,id,全小写。
passwd char[20], // 密码,存放加密后的密文。
realid char[20], // 实际id,大小写混合。
username char[24], // 用户的泥称
userlevel longint, // 64种权限?
numlogins int,
numposts int,
firstlogin time,
lastlogin time,
staytime time, /* 总共停留时间 */
lasthost char[32],
email varchar[100],
address varchar[100],
// 还需要其他数据吗?是否需要留出一定的保留值,以后alter table来
// 增加新的字段时,效率如何?
版面分类表:sclass
classnum int unique, // 分类标识
classid char[20], // 分类的英文id:computer
classname varchar[100],// 分类的中文描述:电脑世界
classtable char[20], // 特殊分类对应的版面表
// 一般来说,每个版面只属于一个分类,对于特殊分类,例如拳头版块,
// 新版面,可以用专门的表来描述
版面表:sboard
boardnum int unique, // 版面的标识(需要吗?)
boardid char[20], // 版面的英文名
boardname varchar[100], // 版面的中文名
boardclass char[20], // 版面所属分类
boardsysop varchar[100], // 斑竹名单
boardposts int, // 版面的文章数
boardlevel int, // 版面的读写权限
indextable char[20], // 版面对应的索引表的名称:aboardid?
texttable char[20], // 版面对应的文章表名称: bboardid?
// 最后两项有没有必要出现,是否可以作为必然对应关系,还是允许
// 出现更大的灵活性?另外版面的大小写问题是否可以直接默认
// 只开头字母大写,
特殊分类版面表:snewboard, sstarboard
boardid char[20], // 版面的id
// 这样的表有必要吗?
版面索引表:acampus,alinux,afootball。。。。。。
id int, // 文章序数,要手动调整????
mark char[1], // 文章标记,m,g,b,d。。。。
title varchar[100], // 文章标题
writer char[20], // 文章作者id
posttime time, // 发表时间
textnum longint, // 对应的编号???不调整
版面文章表
textnum longint, // 文章编号?
textword text, // 文章内容?
// 有必要将索引和文章内容分开吗?从效率上看,况且lazy flush
// 是必然的。删除也是先做个标记。
// 用户中的版面文章是否未读的数据比较繁,是否应该再建一堆的表
// 才能实现呢?
// 投票功能暂不考虑。。。。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings

The methods for viewing SQL database errors are: 1. View error messages directly; 2. Use SHOW ERRORS and SHOW WARNINGS commands; 3. Access the error log; 4. Use error codes to find the cause of the error; 5. Check the database connection and query syntax; 6. Use debugging tools.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.
