Now I'm starting to work on Rails, I looked at the forum, but I did not find anything that could solve my problem.
Here, I have a Category table and it only has a name for the column (there is no duplication in the categories), so I would like the name to be the primary key, then I have the Product table, which has the name, main_photo, description, and I would like to say that the product has only a category, do I need to add a column named category as a foreign key in the products?
The category is said to have many products.
Then in category models, how can I say that the name is the primary key, and how can I match the name of the primary key in the category and the category in the products?
ruby-on-rails foreign-key-relationship
Márcio Duarte Nov 30 2018-11-11T00: 00Z
source share