Proper redundancy of the MySQL field can help improve query speed

Source: Internet
Author: User
CREATE TABLE ' comment ' (
' c_id ' int (one) not NULL auto_increment COMMENT ' Comment ID ',
' u_id ' int (one) not NULL COMMENT ' user ID ',
' Name ' varchar (not NULL default ' COMMENT ' user name '),
' Content ' varchar (+) not NULL default ' COMMENT ' comment ',
PRIMARY KEY (' c_id ')
) Engine=myisam DEFAULT Charset=utf8;

INSERT into ' comment ' (' c_id ', ' u_id ', ' name ', ' content ') VALUES
(1, 1, ' Zhang Ying ', ' trigger test '),
(2, 1, ' Zhang Ying ', ' solve field redundancy '),
(3, 2, ' tank ', ' make the Code simpler ');

Here is a redundant field name, we can use federated search to find the name of the user table in the read comment, why should have redundant fields, because the simple SQL statement execution is more efficient, but not redundant field more the better, redundant fields are more, also increase the database burden.
What I want to do is, when I update the name of the user table, the trigger updates the comment table at the same time, do not write PHP code to update, when the user is deleted, the comment table, the data about the user will be deleted

Proper redundancy of the MySQL field can help improve query speed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.