douchensou6495 2015-02-25 04:59
浏览 43
已采纳

mysql性能和安全相关的问题

I get some issues when i implement product_description table with language .

my process is that i have default table product_description_en to store description and when a client installs new language (Chinese) the php script will create new table product_des_ch and then put the all default data(from the English table) in to the newly created table.then the client can update . My problems are

  1. Is it a security issue that we create the table dynamically while installing new language

2.If we use same table for all languages(the records will be around 500,000) then are there any per performance issues 3.what is the best way for large amount of records to store , i mean same table or separate tables.

Thanx Az

Updated: This is sample product_description table structure for English table and Japan .What you think about this table(we store the all records in a same table and when the client inserts new record for different language only inserting new records ) ,Any feedback please ?

+---------------------------------------------------------------------------+
| product_id | name   | desc | meta_name | meta_desc | key_words | lan_code |
+---------------------------------------------------------------------------+
|          1 |      A |     D|        m1 |      m_d1 |        k1 |       en |
+---------------------------------------------------------------------------+
|          1 |      A |     D|        m2 |      m_d2 |        k2 |       jp |
+---------------------------------------------------------------------------+
  • 写回答

1条回答 默认 最新

  • doukekui0914 2015-02-25 05:11
    关注

    Basic RDBMS design wisdom would put a huge red flag on anything that dynamically alters the table structure. Relational databases are more than flexible enough to handle pretty much any situation without requiring such measures.

    My suggestion as for the structure would be to create a single Languages table to store the available languages, and then a Phrases table to store all the available phrases. Then use a Translations table to provide the actual translations of those phrases into the available languages. Something that might look like this:

    Language
    +----+---------+
    | id | name    |
    +----+---------+
    |  1 | English |
    |  2 | Chinese |
    +----+---------+
    
    Phrase
    +----+-------------+
    | id | label       |
    +----+-------------+
    |  1 | header      |
    |  2 | description |
    +----+-------------+
    
    Translations
    +-------------+-----------+-----------------+
    | language_id | phrase_id | translation     |
    +-------------+-----------+-----------------+
    |           1 |         1 | Header          |
    |           1 |         2 | Description     |
    |           2 |         1 | 头              |
    |           2 |         2 | 描述            |
    +-------------+-----------+-----------------+
    

    For small to medium sized databases, there should be no performance issues at all even using the default database configurations. If you get to huge sizes (where you are counting the database size in terabytes) you can optimize the database in many ways to keep the performance level acceptable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献