MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
darasion
V2EX  ›  MySQL

多对多关系中,除了传统范式的关联表,还有别的什么设计?

  •  
  •   darasion · Mar 17, 2013 · 4708 views
    This topic created in 4874 days ago, the information mentioned may be changed or developed.
    比如传统的关联表设计:

    post 表:
    id, title, content

    tag 表:
    id, name

    post_tag 表:
    post_id, tag_id

    --
    在某些特定情况下(例如:性能是主要瓶颈时)有没有更好的设计?

    都有哪些情况不应该用这种设计?
    Supplement 1  ·  Apr 20, 2013
    3 replies    1970-01-01 08:00:00 +08:00
    alsotang
        1
    alsotang  
       Mar 17, 2013
    我也想知道。。。不过貌似没人回答哈。。。
    keakon
        2
    keakon  
       Mar 17, 2013
    如果你的 tag 的范围是能预先确定,并且种类不超过 64,可以用 SET 类型。
    如果 tag 不需要重命名,且使用 PostgreSQL 的话,可以用数组类型。

    不过在 tag 表较小,post_tag 表正确设置了索引的情况下,还存在性能问题,就表示你的业务模型不适合关系型数据库。
    darasion
        3
    darasion  
    OP
       Apr 20, 2013
    @keakon 多谢多谢.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   942 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 20:48 · PVG 04:48 · LAX 13:48 · JFK 16:48
    ♥ Do have faith in what you're doing.