How is the multilevel classification of classification information designed? -Php Tutorial

Source: Internet
Author: User
Different information, such as recruitment and real estate, can define different fields freely. each field can define fields with different numbers. you can use multiple fields to filter information, how is such a database designed? I think like this: define a category table to classify real estate and recruit...

Different information, such as recruitment and real estate, can define different fields freely. each field can define fields with different numbers. you can use multiple fields to filter information, how is such a database designed?

I think like this:

Define a category table to classify different categories such as real estate and recruitment,
Define an info mark to store information, such as id and category_id,
Define an attribute_name table to store attribute fields, such as area, rent, room, method, and brand,
Define an attribute_value table to store attribute values, id, attribute_name_id, value, and other fields, such as Chaoyang, Haidian, and Dongcheng.

I don't know how to associate information with attributes and attribute values to filter information through multiple attributes at the same time? For example, the area, rent, department, and room types are used to filter information.

I don't know how this multi-dimensional classification is designed. thank you for your advice.

Reply content:

Different information, such as recruitment and real estate, can define different fields freely. each field can define fields with different numbers. you can use multiple fields to filter information, how is such a database designed?

I think like this:

Define a category table to classify different categories such as real estate and recruitment,
Define an info mark to store information, such as id and category_id,
Define an attribute_name table to store attribute fields, such as area, rent, room, method, and brand,
Define an attribute_value table to store attribute values, id, attribute_name_id, value, and other fields, such as Chaoyang, Haidian, and Dongcheng.

I don't know how to associate information with attributes and attribute values to filter information through multiple attributes at the same time? For example, the area, rent, department, and room types are used to filter information.

I don't know how this multi-dimensional classification is designed. thank you for your advice.

No one answered. I am here.

Create an attribute table for different categories to save the attribute values of each product. The multidimensional classification you are talking about is actually retrieving by different attributes.

Create an attribute table for each type, such as the example of the landlord, with attributes such as area, rent, Hall/room, method, and brand.

Product ID Region ID Rent Number of halls Room count Method Brand
1 510703 1000 1 2 Complete [NULL]
2 110103 5000 2 3 Complete I love my family
3 110228 2000 1 1 Single room Zhongyuan property

This is only the most basic attribute, where the area code is used. Method and brand do not use enumeration mainly because there may be other extensions. If the system is complex enough, these items also need to be maintained by a separate table.

In the code, for each type of product, insert data to this table during registration. During the search, the product category is roughly determined based on the search conditions. after entering the category check page, detailed attributes are listed for selection. For multi-value attributes, you can use commas to separate them (varchar(n)), UselikeQuery, and so on.

It is not recommended to query the data directly in the database.
We recommend that you create an open-source search engine and add all these fields to the index for retrieval.

Http://sqlfiddle.com /#! 2/5 dfcb/5/0
You can refer to this design. And I think it's simple and straightforward.
But I don't think he has written it ..

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.