( 1)在mysql引擎中,MyISAM更好,InnoDB更好?
2)我想要编写一个cms,它可以用多类添加一个帖子,我必须如何设计我的数据库才能通过一些查询获得更好的性能?
在php中,如何列出哪些类别的帖子,例如=1?
谢谢
发布于 2011-04-15 11:27:09
1)如果您需要DB级别上的外键关系,请使用InnoDB,否则使用MyISAM
2)可以使用这样的模式将所有类别存储在一个表中
create table categories (
Category_ID int NOT NULL,
ParentCategory_ID int NOT NULL default 0,
CategoryName varchar(150)
);使用Category_ID主键
3)
$sql = select * from posts where category_id = 1;
mysql_query($sql);编辑: post表的架构(示例)
create table posts (
Post_ID int NOT NULL,
Category_IDs varchar(50) NOT NULL,
POSTDescription varchar(1000),
POSTTime int NOT NULL
)Post_ID是posts表的主键。
注意,如果您的帖子属于第一、第二和第三种类别,那么Category_IDs现在是它中类别的varchar存储值,如1,2,3。对于删除属于类别1的所有帖子,您将运行以下查询
$sql = DELETE
FROM `posts`
WHERE FIND_IN_SET( '1', `Category_IDs` ) >0;发布于 2011-04-15 11:43:23
没有明确的答案,因为这取决于您的需求,但是,许多人已经提到了如下内容:
F 213要小。
然而,没有多少人会提到innodb集群主要关键索引,以及一个设计良好的innodb表将如何很容易地执行等效的myisam表。
以下是两个解释聚集索引的链接:
http://dev.mysql.com/doc/refman/5.0/en/innodb-index-types.html
http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/
另外,请看以下示例和文章(第二个示例可能具有特殊的相关性)
MySQL and NoSQL: Help me to choose the right one
Rewriting mysql select to reduce time and writing tmp to disk
Optimal MySQL settings for queries that deliver large amounts of data?
http://www.mysqlperformanceblog.com/2007/01/08/innodb-vs-myisam-vs-falcon-benchmarks-part-1/
希望这会有所帮助:)
https://stackoverflow.com/questions/5675916
复制相似问题