On 2022-10-29T17:41:52 +0700 Andreas Reichel <[email protected]> wrote:
> On Sat, 2022-10-29 at 09:46 +0000, 'Mark Raynsford' via H2 Database > wrote: > > I think the natural way this would be expressed as a plain Java data > > structure would be: > > > > Map<Integer, Set<Integer>> > > Greetings, > > based on your PRIMARY KEY it would be MAP<Key, T> with a Class Key ( > int group, int member ) and a class T (int group, int member). > If group represents the key, and member represents the object, then > PRIMARY KEY(group) and MAP<Integer, Integer>. Hello! I'm not sure about this. Wouldn't PRIMARY KEY(group) limit groups to a single member? Imagine I had the following rows: (1, 1) // Group 1 contains member 1 (1, 23) // Group 1 also contains member 23 (1, 24) // Group 1 also contains member 24 (2, 4) // Group 2 contains member 4 (2, 5) // Group 2 contains member 5 With PRIMARY KEY(group), the above rows would violate the unique constraint. With PRIMARY KEY(group, member), the above rows would be accepted, and I'd be (correctly) prevented from saying that a member is in a particular group multiple times. -- Mark Raynsford | https://www.io7m.com -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/h2-database/20221029105032.3f77e8f2%40sunflower.int.arc7.info.
