Main Goal: Query the database to determine what the lab technician should do next.
What I am trying to accomplish
I am designing a laboratory database where each of the following entities requires exactly one parent (to the left) and at least one child (to the right): request (REQ) -> sample (SAM) -> test (TST) -> measurement (MEA)
.
Each entity has the following:
- Template - (or type) of that entity (test templates might include: pH test, titration, etc)
- Custom Tables - table fields which only apply to that template
- Calculations - results of relevant formulas from data for that entity (and children)
Our specifications are often very complex. For example, a spec might state, "A third measurement may be taken if the first two are out of spec," or "Perform the long test method if the quick test method fails."
I want a function which takes an ENTITY_id
and (based on already entered data and specification rules) returns a list of available child templates.
Question
Are Pipelined Functions (as described by tuinstoel below) the best way to implement the needed_children() function that I'm trying to achieve?
If not, what do you suggest?