Amazon So our entity is Keyword, and each Keyword can have a set of Keywords as its parents and a set of keywords as its children. This means this mapping is many-to-many and we need a join table to represent the relationships! DON'T WORRY; a join table is simply a table that keeps track of who are whose parents and who are whose children. Questions?
The following is the SQL script to create the tables.
) engine=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
As you can see 'keyword_to_keyword' is the table for keyword to join itself. The parent_id in keyword_to_keyword specifies the parent and child_id specifies the child. I included last_modified_time and create_time columns because it's my habit to know when a row was created and when it's last updated, but you don't have to if you don't want to. Questions? Let me know!
Now that we have our table in database let's create the corresponding Java class!