The "related articles" result in a case that is more advanced than the relevant ranking, efficient writing

Source: Internet
Author: User
The result of "related articles" is an example of a higher ranking. in this case, an efficient writing method was obtained. Finally, my article system was edited by sky94132003 from 2014-08-2403: 53: 35, want to follow multiple pieces to see if there is any possibility to achieve 4 tables & nbsp; basic introduction content & nbsp; Article master table idlid & nbsp; the result of "related articles" is a case that is more relevant than the previous one.

This post was last edited by sky94132003 at 03:53:35

My article system, I want to follow multiple entries
To see if there is any possibility.

Four basic table descriptions
Content article master table
Id
Lid = the id of the collection, which is saved in the format of (1, 2, 3)
Tags = ID of the related TAG, saved in the format of (1, 2, 3)
Typeid = the Category ID is only one number.
Collection
Lid
Name

Tags
Id
Name
Category
Typeid
Name

Typeid = Category ID.
Tag = tag,
Lid = a collection, but an article can be put into multiple collections, such as PHP + MYSQL + AJAX without refreshing comments
Users may choose PHP collections, MYSQL articles, and AJAX collections.

If the TAG is shared by the entire site, it will not be added if it is repeated.
Therefore, you cannot create a category list for your own articles, so the collection function is displayed.


Because a part of the article already displays other articles in the current collection

Therefore, in the article, the files in the collection should be at the beginning of the article.

So the prepared relationship ranking is
1. TAG-related
2. collection
3. Latest articles of the current category

Why is it divided into three times ???

Because I am afraid of being too tagged, and I have not used the collection function ....
So the last step is the current classified article.



Current article
The TAG is 3, 14.
Lid = 7, 12
Typeid = 2

SELECT * FROM 'content' WHERE 'tags' IN (3, 14) order by 'time' desc limit 10
SELECT * FROM 'content' WHERE 'lid' IN (7, 12) order by 'time' desc limit 10
SELECT * FROM 'content' WHERE 'typeid' = '2' order by 'time' desc limit 10


Ten articles on the front-end
It was originally prepared and divided into three times, and each time taking 10 records is the safest

Think about it later... it is also troublesome to merge arrays or something. The point is to take too much data, but the front-end only needs 10

So in another sentence
SELECT * FROM 'video _ content' WHERE 'tags' IN (3, 14) or 'lid' IN (3) or 'typeid' = 2 LIMIT 10

However, it seems that you can rank again by TAG> Collection> category...

How can I request it?

The requirement seems quite troublesome. because 50% of the lower part of the page displays related articles, it is very important to operate
------ Solution --------------------
It is not good to use or not in SQL statements;
If the data does not need to be too timely
Cache the data with the combination of your three SQL statements for a period of time (half an hour, one hour, or even a little longer)
Because your data is dead data, no page views, no comment, etc.
------ Solution --------------------
Do you mean that if you want to get 10 tags, you should first get 10 Tags. if not, you should get lib and then type?

If so, will your SQL be faulty!
------ Solution --------------------
Use full-text search

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.