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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -