D
D
Danil2016-06-01 17:12:57
MySQL
Danil, 2016-06-01 17:12:57

How to store a list of categories in mysql?

There is news, she has a list of static categories to which she belongs. How to store this list of categories in the database? Table in the form: categoryName1:true, categoryName2:falseand so on? Or is there another option?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2016-06-01
@Veneomin

category tree table: ID;categoryName;parentCategoryID
news table: ID;text;timestamp;author
link table: ID;categoryID;articleID

P
Petttttro, 2016-06-01
@Pettttttro

Since @xmoonlight answered above
I can add that this type of relationship is called many-to-many

N
neronru, 2016-06-01
@neronru

Since you say you have static categories, it's fine to use Nested Sets to store the categories. With a small number of category updates, they are much faster ...
Here is an example: zabolotnev.com/mysql-nested-sets

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question