mysql - 大部分?jǐn)?shù)據(jù)沒有行溢出的text字段是否需要拆表
問題描述
比如一個論壇系統(tǒng)的回帖表,多數(shù)情況下這個回帖的內(nèi)容都是簡短的,只有少部分內(nèi)容長。
而在顯示中這個內(nèi)容字段是常用的,還有必要把這個內(nèi)容字段單獨拆出來嗎?
<?phpnamespace KooguaModelEntity;class Reply extends EntityBase{ const STATUS_PENDING = 1; // 待定 const STATUS_APPROVED = 2; // 審?fù)? const STATUS_REJECTED = 3; // 審拒 const STATUS_DELETED = 4; // 刪除 /** * 主鍵編號 * @var integer */ public $id;/** * 回復(fù)內(nèi)容 * @var string */ public $content;/** * 提及用戶 * @var string */ public $mentions;/** * 用戶編號 * @var integer */ public $userId;/** * 主題編號 * @var integer */ public $topicId;/** * 版塊編號 * @var integer */ public $forumId;/** * 置頂標(biāo)識 * @var integer */ public $sticked;/** * 狀態(tài)標(biāo)識 * @var integer */ public $status;/** * 評論計數(shù) * @var integer */ public $commentCount;/** * 關(guān)注計數(shù) * @var integer */ public $watchCount;/** * 收藏計數(shù) * @var integer */ public $favoriteCount;/** * 贊同計數(shù) * @var integer */ public $agreeCount; /** * 反對計數(shù) * @var integer */ public $opposeCount;/** * 舉報計數(shù) * @var integer */ public $reportCount;/** * 創(chuàng)建時間 * @var integer */ public $createTime; /** * 更新時間 * @var integer */ public $updateTime; public function getSource() {return ’Reply’; } public function beforeCreate() {$this->createTime = time(); } }
問題解答
回答1:個人感覺沒必要,從語義上來講內(nèi)容屬于回帖表比較關(guān)鍵的數(shù)據(jù),另外分出來的話,每次需要連表查或者分兩次差太麻煩(而且這種基礎(chǔ)數(shù)據(jù),幾乎是100%需要的,如果是額外信息到可以考慮放出來)。
另外如果表太大的話,可以考慮分庫分表。
回答2:你可以先把你的表結(jié)構(gòu),粘貼出來。研究研究,我們在討論討論
回答3:規(guī)定回帖字?jǐn)?shù),沒有必要拆表。
相關(guān)文章:
1. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題2. html5 - 為什么有的時候要在網(wǎng)頁中加偽元素3. html - Python2 BeautifulSoup 提取網(wǎng)頁中的表格數(shù)據(jù)及連接4. python - PyCharm里的一個文件不小心忽略了wx包5. html5 - css 這種六邊形的邊框怎么畫?6. html5 - javascript讀取自定義屬性的值,有的能夠取到,有的取不到怎么回事??7. 小白學(xué)python的問題 關(guān)于%d和%s的區(qū)別8. win10 Apache24+PHP8.0,Apache不能正常加載php.ini。9. javascript - 關(guān)于微信掃一掃的技術(shù)問題10. html5 - 請問利用font-face定義的字體怎么在canvas里應(yīng)用?
