# Example: Execution dependencies

Each order can have multiple dependencies as well as multiple dependent orders. The application stores each edge as an individual record identifying the order as well as its dependent order. The dependencies must be acyclic.

## Example: Execution dependencies

The application also tracks whether a dependency is resolved for an edge or not. This helps in
fetching all orders that are yet to be processed and are eligible to be picked up for processing.
For example, consider the following execution dependency tree structure:

The application inserts the following records in the YFS_TRANSACTIONAL_RELATION table.

In this example, the orders that are ready to be processed are the ones that have
no dependencies identified.

This Order | Related Order | Relationship Type | IsDependencyResolved |
---|---|---|---|

Order-1 | Order-11 | DEPENDS_ON | |

Order-1 | Order-12 | DEPENDS_ON | |

Order-1 | Order-13 | DEPENDS_ON | |

Order-11 | Order-111 | DEPENDS_ON | |

Order-11 | Order-112 | DEPENDS_ON | |

Order-11 | Order-131 | DEPENDS_ON | |

Order-12 | Order-131 | DEPENDS_ON | |

Order-13 | Order-131 | DEPENDS_ON | |

Order-13 | Order-132 | DEPENDS_ON | |

Order-132 | Order-1322 | DEPENDS_ON | |

Order-1322 | Order-1321 | DEPENDS_ON | |

Order-1321 | Order-131 | DEPENDS_ON |

In the First Round: Order-111, Order-112, Order-131 are processed. When these orders are processed or work is done, their dependent orders must have the respective edges marked as resolved.

After the first round of processing, the application inserts or updates the following records in
the YFS_TRANSACTIONAL_RELATION table.

Similarly, the application keeps processing the related orders and when the orders
are processed or work is done, their dependent orders must have the respective edges marked as
resolved. Finally, after processing all the dependent orders when Order-1 is processed or work is
done, its dependent orders must have the respective edges marked as resolved. Since, Order-1 has no
dependent orders, the processing is complete.

This Order | Related Order | Relationship Type | IsDependencyResolved |
---|---|---|---|

Order-1 | Order-11 | DEPENDS_ON | |

Order-1 | Order-12 | DEPENDS_ON | |

Order-1 | Order-13 | DEPENDS_ON | |

Order-11 |
Order-111 |
DEPENDS_ON |
Y |

Order-11 |
Order-112 |
DEPENDS_ON |
Y |

Order-11 |
Order-131 |
DEPENDS_ON |
Y |

Order-12 |
Order-131 |
DEPENDS_ON |
Y |

Order-13 |
Order-131 |
DEPENDS_ON |
Y |

Order-13 | Order-132 | DEPENDS_ON | |

Order-132 | Order-1322 | DEPENDS_ON | |

Order-1322 | Order-1321 | DEPENDS_ON | |

Order-1321 |
Order-131 |
DEPENDS_ON |
Y |