Answer the question
In order to leave comments, you need to log in
Do I need an id field with primary key if there is id_cat to join mysql tables?
You need to create several tables and link them together.
Do I need to create a separate id field with a primary key in each table and use an increment for the field, as well as have a separate id field (for example, id_category, in general there are more fields to link with other tables).
And is it necessary to use 2 id fields for child tables too?
The base will be very large and will expand very quickly.
Answer the question
In order to leave comments, you need to log in
I doubt that id_category will ensure the uniqueness of records for a given table.
Naturally, a primary key is needed, whether it will be an auto-increment or not is up to you to decide.
It's not entirely clear from your question about the structure of the tables.
In general, for link tables, you can make composite keys for two or more fields.
For example, there is a table, category, product and a table of relations product_category with fields category_id, product_id, then the key will look like this - PRIMARY KEY(category_id, product_id).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question