2

Is there a a container in Java to store objects with many-to-many relations?

As an example I want to implement a students - subjects database. A student can choose more than one subject and any subject can be studied by unlimited number of students. I want to do search of students by subject with constant or logarithmic time and the same applies to search of subjects by student.

  • From Guava, you may want [`Multimap`](https://google.github.io/guava/releases/snapshot/api/docs/com/google/common/collect/Multimap.html) – 4castle Oct 24 '16 at 14:40
  • Still a nice question; you might want to start reading here https://github.com/google/guava/wiki/NewCollectionTypesExplained too – GhostCat Oct 24 '16 at 14:40
  • You could also use JPA. – tak3shi Oct 24 '16 at 14:41
  • You can also use [new graph API](https://github.com/google/guava/wiki/GraphsExplained) which will be present in [Guava 20](http://google.github.io/guava/releases/snapshot/api/docs/com/google/common/graph/Graph.html). – Grzegorz Rożniecki Oct 24 '16 at 16:04

0 Answers0