php - Articles and Categories - The efficient way -
i want add categories website - more complex sorting.
lets have article a. now, want a under main category a, on category c thats parent b.
i thought of doing this: article have main category field, , parent_ids
parent_ids every category item belong to. problem is: lets have: parent_ids: |1|5|2|7|.
now in category id - 7.
how select query like?
select * categories parent_ids '%|7|%'
is efficient? there better idea?
never store multiple values in 1 column. column values in normalized database should atomic (single-valued).
the relationship between articles
, categories
many-to-many. means should have separate table, such article_category (article_id, category_id)
containing 1 row each category each article in.
Comments
Post a Comment