Can this MySQL db be improved or is it good as it is?

后端 未结 4 751
清酒与你
清酒与你 2020-12-21 19:22

In a classifieds website, you have several categories (cars, mc, houses etc). For every category chosen, a hidden div becomes visible and shows additional options the user m

4条回答
  •  我在风中等你
    2020-12-21 20:16

    Your design is very much tied to the underlying products. Also you are putting what appears to be mutually exclusive data in different columns (e.g. surely a house can't be both a villa and an aprtment?) I'd go with a much more generalized form, something like:

    Category 
    Classified
    Poster
    

    As in the OP, but with primary keys added/declared.

    Then group all the category specific attributes into a single table - like

    Std_Tags {id, category, tag}
    {0,Cars,year}
    {1,Cars,fuel}
    {2,house,type}
    {3,house,rooms}
    

    With values in another table:

    classified_tags {std_tags_id, classified_id, value}
    {0,13356,2005}
    {2,109,villa}
    {0,153356,diesel}
    

    This also simplifies the building of input forms becuase the template is explicitly stated also, by adding a table like:

    Allowed_values {std_tags_id, value}
    {1,diesel}
    {1,petrol}
    {1,LPG}
    {2,Villa}
    {2,Apartment}
    

    Then much of the data entry could be done using drop-down lists, conforming to standard searches.

    C.

提交回复
热议问题