Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL - Many column in an index? Or one by one?
    primarykey
    data
    text
    <p>Suppose that a product can have up to five (5) complaints. In this case, there is a table with five (5) columns. These five columns directly involved in the other table, where reports claim codes.</p> <p>See in: <a href="http://img263.imageshack.us/img263/4990/01mysql.jpg" rel="nofollow">http://img263.imageshack.us/img263/4990/01mysql.jpg</a></p> <p>From this moment, I have to make a relationship between two tables. So which of the following is more correct to create indexes:</p> <p>a) creating index one by one?</p> <pre><code>ALTER TABLE `complaint` ADD INDEX (`code_01`) ALTER TABLE `complaint` ADD INDEX (`code_02`) ALTER TABLE `complaint` ADD INDEX (`code_03`) ALTER TABLE `complaint` ADD INDEX (`code_04`) ALTER TABLE `complaint` ADD INDEX (`code_05`) </code></pre> <p>b) That all fields in a single index?</p> <pre><code>ALTER TABLE `complaint` ADD INDEX (`code_01`, `code_02`, `code_03`, `code_04`, `code_05`) </code></pre> <p>I believe the best option is a), because if I choose option b) and by accessing "Relation View" in phpMyAdmin, it shows that there are other fields saying that there is "No index defined!" in columns code_02, code_03, and code_04 code_05.</p> <hr> <p>ATTENTION - FOR INSERT AND UPDATE:</p> <p>If I use option b) and enter a code on record with columns code_02, code_03, and code_04 code_05, MySQL does not advise any errors that the code entered does not exist. Only returns a success message which should really be incorrect. So in this particular case, I have to use option a), right?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload