what are the minimum tables I need for many to many 开发者_如何转开发associations in Hibernate?
Apart from the tables for the entities you want to associate, you need an association table. In its simplest form, it would contain only two foreign keys, one for each of the entities.
By design, relational databases management systems only support one-to-many relationships. The only way to represent physically a logical many-to-many relation between A and B is thus to introduce a third junction table AB with two one-to-many relationships A -> AB <- B where the primary key of AB is formed from the two foreign keys (i.e. values that are primary keys in A and B).
So to summarize, you need 3 tables. Below an illustration of the famous Order / Product samples:
alt text http://www.about-access-databases.com/images/many_to_many.jpg
精彩评论