Hello. There is a table in the database - products . Each product has a country of origin, for normalizing the database, made a table of countries where there are fields id and name . Next, I make the table M: M - products_has_countries , where I need to store in each record product id and country id in order to link them. Question: Is it possible not to create a field with primary key?
|
2 answers
It depends on what you need. If products_has_countries is an auxiliary table with many-to-many links, then of course the primary key is optional.
But it seems to me that your products cannot have two producing countries. And country_id should be right in the products table.
|
The 21st century the same product can be produced in different countries, for example, machines, processors.
A table without a primary key can be created and in this case it is not needed in the classical form. You can create a composite primary key for 2 fields to avoid duplication.
|
primary key(id-продукта,id-страны)). And yes, of course, no additional fields are needed - Mike