Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Many to many?

+12 votes

Has anyone come up with a creative way to map "many-to-many" connections yet? 

I was thinking of using the Vector class, which is a subclass of AbstractList which implements the List interface. I will have to do some more research on the capabilities of the vector class first, but was curious what other groups were thinking of using for the project. 

asked Sep 21, 2016 in CSC 285 (F16) by Michael Carlson (100 points)

2 Answers

+5 votes
My group was thinking of doing 2 arrayLists so that it can work in more flexible situations.
answered Sep 21, 2016 by Kyle Zeberlein (100 points)
Like Kyle said, we're making two InteractionLists so any number of people can be on either side of the interaction. Not sure if it's necessary but it made the most sense to us.
+4 votes

Kyle's answer is an interesting one.  This might be good -- but I'm not sure whether we ever need the flexibility to connect one list of people to another list, or not.  Perhaps we should talk to the client more about that.  

I think it may be enough to have one ArrayList peopleList, and a separate connectionType field to say whether it's one-to-many (which would connect the peopleList.get(0) to each of the other elements: peopleList.get(1)...peopleList.get(N-1)) or many-to-many (which would connect every element of peopleList to every other element of peopleList).

Perhaps this connectionType could include directionality:

one-to-many undirected
one-to-many directed
many-to-many (undirected)  

I don't think many-to-many directed makes sense...

answered Sep 24, 2016 by Forrest Stonedahl (3,438 points)
...