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 7637647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:59:40+00:00 2026-05-31T07:59:40+00:00

This is a follow-up from my question here: How to record sequential collections of

  • 0

This is a follow-up from my question here: How to record sequential collections of records in MySQL

In short, I want to implement in MySQL a table of recipes and another of instructions. A recipe is a sequential series of instructions or other recipes. So for example you could imagine a Peach_preserve recipe, and a Peach_tart that uses the Peach_preserve, plus a series of other steps (instructions). Peach_preserve could be used for many other recipes.

In my previous question I was recommended a design to allow for a specific order for each instruction within a recipe:

recipe
id  name
1   Recipe1
2   Recipe2

recipe_instruction
recipe_id  instruction_id  sortorder
1          5               1
1          3               2
1          4               3
2          6               1
2          7               2
2          3               3
2          6               4

What I would like to do now is to incorporate the idea that within a recipe a sub-component might be another recipe rather than an atomic / discrete instruction. So my idea is to do it this way:

recipe
id  name
1   Recipe1
2   Recipe2

recipe_instruction
recipe_id  step_id  isRecipe    sortorder
1          5             F           1
1          3             F           2
1          4             F           3
2          1             F           1
2          1             T           2
2          2             F           3
2          1             F           4

Here you can see that Recipe1 is made of 3 instructions, and Recipe2 is made of one instruction, then Recipe1, then another 2 instructions, one of which is a repeat of step 1. I thought of other ways to capture this idea but they involve a bunch of null entries. What I don’t like in the above is that the key is made of the 4 attributes…

My questions are:

  1. Is it a good idea to incorporate a recursive idea inside a db?
  2. If so, is this the way to do it, or can it be improved upon?

QUICK EDIT: I’m starting to read on hierarchies. In my example, each one recipe can have several parents.

  • 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-05-31T07:59:42+00:00Added an answer on May 31, 2026 at 7:59 am

    This is a very common technique. It is used to store hierarchical data (you call it recursive) within a db.

    However you will have to manage the integrity in your application, because a foreign key cannot be used, since the relation is conditional to the isRecipe flag.

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

Sidebar

Related Questions

This is a follow up from my question: MySQL: Querying a table and possibly
This is a follow up question from here . Where I want do go
This is a follow-on question from the one I asked here . Can constraints
All, this is a follow up from a previous question here: C# formatting external
This is a follow up question from my previous one found here I need
This is a follow on question from my previously answered question here: Reading characters
This is a follow up question from here specifically concerning its answer . From
this is a follow up question from this one , I don't want to
This question is a follow on from the one that was asked here .
This is a follow up from a question of mine that was just answered

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.