How would I use Java Collections to simulate an SQL INNER JOIN operation?
In a database, I have:
TABLE Person
KEY NAME
11 Senor
other non-important entries...
TABLE Thing
KEY ITEM
AA Moustache
BB Sombrero
CC HotSauce
other non-important entries...
TABLE PersonToThing
PERSON_KEY THING_KEY HAS
11 AA Y
11 BB N
11 CC Y
other non-important entries...
I want to emulate the SQL statement:
SELECT Person.NAME, Thing.ITEM, PersonToThing.HAS
FROM Person
INNER JOIN PersonToThing ON Person.KEY=PersonToThing.PERSON_PKEY
INNER JOIN Thing ON Thing.KEY=PersonToThing.THING_KEY
WHERE Person.NAME="Senor";
Which yields the resultset:
NAME ITEM HAS
Senor Moustache Y
Senor Sombrero N
Senor HotSauce Y
I want to put each table in a Java Map.
I have exported the tables into INSERT TABLE statements.
I will populate the Maps by looping through the INSERT TABLE statements.
Running a relational database modelling system is simply not a possibility, unfortunately.
What I don't understand is how do I organize the Collections or Maps and how do I link them together to mimic the INNER JOIN operation?
Thank you in advance for your time and any help you can give.