I need to make a form for adding news. It should have a function of assigning several categories, for example, the article Titles 1 should be included before the category: Category 1 and Category 2. The question of how to properly organize the database, I did this: enter image description here

An example of writing to news_categories:

1;id_Названия1;id_Категория1; 2;id_Названия1;id_Категория2; 

If it is correct to design a database in such a way, then how to add news correctly through a news request, leave what we need to know in advance the ID of the news to be collected.

  • 2
    In general, that is true. Although in the news_categories id field is not needed. There are enough two fields FK and primary key including both of these fields. ru.stackoverflow.com/questions/546703 - Mike
  • one
    And about the addition of news ... you probably write the news and at the same time categories. so we do insert into news, after which we get last_insert_id() and with this id we insert the entries into the category table - Mike

0