When PHP uses MYSQL as a database, does the content field have to be split into tables?

Source: Internet
Author: User
When PHP uses MYSQL as a database, does the content field have to be split into tables? For example, a table has an id name content
There is no need to process this content.
Distribute to 10 tables?

I want to know how many levels of table shards can be compared to improve efficiency or is not necessary at all?


Reply to discussion (solution)

In my personal experience, I will add the table id to the other 10 tables instead of the content. Generally, the id occupies less space than the content.
Another point is that id is generally a unique identifier.

Primary table id name
There are 10 sub-tables
Id aid content the aid in this section corresponds to the id in the main table.

No!
Even if you want to split a table, this is not your method.

There is no need to read 10 tables if you want to read them and try again?

There is no need to read 10 tables if you want to read them and try again?



Not fixed
The document table is content: id cid title.
The topic table is channel: id cid name
Then different columns correspond to different sub-tables. for example, the contet01 content02 content03 field is id aid content.

For example
First, you need to find the number of columns where ID 2 belongs. for example, an article with ID 2 belongs to column 3.
The content table corresponding to column 3 is content03

Then the program will directly find the content field value of aid = 2 from content03

Then the program will directly find the content field value of aid = 2 ????
Is this possible?

Then the program will directly find the content field value of aid = 2 ????
Is this possible?



If the program is not looking for content with aid = 2, first find the corresponding column ID in the article table with aid = 2, for example, column 3.
Then there are settings in column 3. all contents that are attributed to column 3 are in table content03.

Then, the program goes to Table 03 to find the content value of aid = 2 and output it.

In the middle, the columns are designated as intermediate columns.

Aren't you looking for trouble?

Aren't you looking for trouble?



In the past, when I used a CMS of ASP, it was designed to use access database sub-tables to make the data more efficient.

But I don't know if such a score in mysql is meaningless.

Table Sharding is not the method you mentioned. if there are thousands of columns, isn't it necessary to add thousands of tables?

There is no need to combine the sub-table and column table of the article.
If you want to split an article into tables, you can use the article id to split the table.
For example, the id % 10 in the article will get, which is the name of the table shard.
You can determine the table shard where the content is located based on the id.

For example, find the article content with id = 2. You can use $ id % 10 to get 2 and then read the content directly in content02.

No!
Even if you want to split a table, this is not your method.



Is this necessary?
Article
Id title description (forgive me for not being good at English and cannot remember)
Content
Id content
Is it necessary to separate them? Are some char int and other automatic table sharding fields of fixed length and nvarchar text?

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.