Storing OOP data in a Mysql DB

Hello experts,

I am working on an expert system which will run through a website I have in development.  The purpose is to provide step by step instructions based on Project by state, so no matter who is working the queue, we end up with a consistent build.  So this question is based in OOP theory and how to bring about a result (storing the data in a database...  Because if you can put it in there...  I can retrieve it... hopefully, lol.  So I am going to use a dumb made up example so I don't give up the secret sauce.  So lets go with cake.   Bob is our baker, and Karen is our master chef.  Karen has checked with each state law on how to make each specific kind of cake that we have seen, and we need to consider a default outcome for recipies she hasn't seen.

So Bob looks in his queue and sees a ticket to make a Strawberry Cake in Colorado.  Karen has predefined that Bob need to 1) pour batter A  into 2 baking pans, 2) bake the cakes 3) ice the middle using frosting C and then 4) send to shipping.  Bob see's the "preflight" instructions and follows them diligently.   Bob once again looks in his queue and sees a ticket for a Strawberry Cake in Hawaii  (State law says we have to use batter B (gluten free)).  Karen has predefined that Bob need to 1) pour batter B  into 2 baking pans, 2) bake the cakes 3) ice the middle using frosting C and then 4) send to shipping.  

A ticket can have up to 3 cakes on it ever,  And Karen needs to be notified whenever there is a request that does not have a preflight instruction.  

So if you have read through all of that, how would you design the database to hold the data?
LVL 9
the_b1ackfoxTechnophileAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Likely best to store your data as JSON.

So your data will... just be data... Your code will be OOP to pack/save/retrieve/unpack/use your JSON data.

You can also use other data forms like YAML + MySQL provides a huge amount of built in intelligence around JSON data.
Dave BaldwinFixer of ProblemsCommented:
Before you can design the database, you have to decide how you are going to recognize the conditions involved in making the decisions.  It looks to me like your selection process needs to list the available recipes along with 'Other' which is the condition where Karen gets notified.  That's the simple version.  Maybe a form that includes the necessary options for doing the data lookup.
the_b1ackfoxTechnophileAuthor Commented:
The condition for notification will be pretty easy...  Cake+state has no recipe then notify Karen.  We'd use a form to capture the cake requests, and Karen would also have a form to assign steps for the Cake+State combo
CEOs need to know what they should worry about

Nearly every week during the past few years has featured a headline about the latest data breach, malware attack, ransomware demand, or unrecoverable corporate data loss. Those stories are frequently followed by news that the CEOs at those companies were forced to resign.

lenamtlCommented:
So when new cake request is done (new order), Karen should receive a notification  to check the order then she will need to add and assign the steps when this done this should change the order status let say to Assigned...
So the order may have several status, New, Assigned, Cook, Delivered ext....
Then you can check with a cron job every x (hours) to check if Karen have done the part of job let say if an order still have the "New" state
by checking the status of the order.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
You can use CRON, as lenamtl suggested.

Sometimes more immediate/realtime notifications are required.

For this, you'll use triggers to run some external script.

Tip: Plumb your triggers to run some given single script, passing verbs to one script to invoke given actions.

This collects all code into a single script. Then if required, have your trigger script dispatch other scripts.

Taking this approach means you have a single dispatching script run for all triggers, which provides a common setup for adding new triggers + tends to simplify debugging over time.
lenamtlCommented:
If you are not on Linux you can replace the cron job by Windows task management.

Or you can use MySQL Event Scheduler fantastic to use when available on PHPMyAdmin
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Object Oriented Programming

From novice to tech pro — start learning today.