Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8660773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:20:32+00:00 2026-06-12T16:20:32+00:00

I am attempting to build a Java program that stores food recipes for myself.

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:20:33+00:00Added an answer on June 12, 2026 at 4:20 pm

    You should change your model and create a table associating an ingredient with all its names.
    Every ingredient that is equivalent to carrot will shere the same id. Here is an example:

    table Ingredient(id, name)
    
    id    Name
    ---------------
    1    carrot
    1    shapdoodle
    1    morot
    2    potato
    2    patata
    3    sugar
    3    brownsugar
    3    anothernameforSugar
    

    And a table for recipes:

    table recipe(id, name, preparation_time)
    1    carrot cake    45
    

    A 3rd table to associate a recipe with its ingredients

    table recipeToIngredient(recipeId, ingredientId)
    1    1
    1    3
    

    In this example, I defined a “carrot cake recipe” which has ID 1
    This recipe has 2 ingredients : carrot (id 1 in table ‘ingredients’), and sugar (id 3)

    To retrieve all the recipes involving carrots/morots/etc :

    SELECT recipe.name FROM recipeToIngredient, recipe
    WHERE recipeToIngredient.recipeId=recipe.id
    AND ingredient.id = recipeToIngredient.ingredientId 
    AND recipeToIngredient.ingredientId = (SELECT id FROM ingredients WHERE name'carrot')
    

    Basically, what we’ve done here is to put an ‘id’ field for the ingredients, instead of using your model where the ingredient name is the primary key. This way, while the name will change according to the language, the id always the same for a given ingredient, and you can run queries according to the id, not the ingredient name.

    Let me know if I can help/explain more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just downloaded a FOSS (Java) project that I am attempting to build on
I am attempting to build a Java web project on NetBeans 6.8, but I
I'm attempting to build a JSF/Hibernate application using Java 7 and Tomcat 7. I
I'm attempting to build a method call from strings that have been passed into
I am attempting to build a backup script that moves a tar file from
I'm attempting to build some C++ code that requires the Windows 7.0 SDK header
I am currently attempting to revise a Java Homework program for my Data Structures
I'm attempting to build a regular expression that will match against the contents of
I am attempting to deploy a Java application from Eclipse (Version: Indigo Release, Build
Attempting to build a C# NPAPI plugin I have found a tutorial which describes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.