I am attempting to build a Java program that stores food recipes for myself. The program should be able to store, search and change recipes stored in a database. Currently I am using Access 2003 since I am accustomed to it but I will most likely use MySQL later on.
The issue here is most likely very basic but what I am having a problem with is implementing my logical model and I'd like to know how solve this or if there are any better ways to do this.
So here's the thing, here's a concrete example: I want to store ingredients in the database, like "carrot". However many items have alternate names, especially since I am not even english so: Let's say Carrot is Carrot in english. Now Carrot is "Morot" in my language. Maybe later on I watch Jamie Oliver's shows and he calls the carrot something like "shapdoodles" or something.
The reason I want to store these ingredients is because if I add these three recipes and then later on search on "carrot", I want the program to list not only recipes involving carrots but also morot and shapdoodles because, well, they are also carrots, just different names!
It sounds simple enough and at first I thought it was merely as easy as to have a table "Ingredient" with one textfield. The text would be a primary key and it would store the ingredient name such as "carrot" or "shapdoodle". This table would be connected with the table "Ingredientlist" and Ingredientlist would lead to "RecipeDescription" and so on.
I assumed I could simply add another table with two textfields, name and alternatename and just make the Ingredient's textfield a foreign key to both of these two textfields and these two textfields together would serve as the primary key for the table. I was kinda thinking of this kind of result:
AlernateIngredientTable:
carrot shapdoodle
carrot morot
And so on... So when later on I could simply send queries to find everything in this table that is related to "carrot" and from there on find the recipes involved with carrot or shapdoodles or morot.
Well, since I could not add the same foreign key to two fields in a table I am kinda lost!