database - a question on many-many relationships -


i have following tables

  1. items
  2. similars
  3. items_similars = pivot table

items->similars has many-many relationship

the items_similars has following field

  1. item_id
  2. similar_id

if using innodb engine, need create relation between items.id , items_similars.id? or between similars.id , items_similars.id? or both?

are there advantages in doing or in not doing so?

many-to-many relationships, afaik, can implemented via transition tables (pivot tables) in rdbms. "items_similar" table should have @ least "items_id" , "similar_id" foreign keys "items" , "similars" tables' primary keys.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -