Find parent name in database

I am working on a Restaurant model. Suppose there are many orders at a given time
order-001
order-002
and now I am saving order-003.

At this point of time from python file how do I find the parent name from sql table?
How do I use “get_parentfield_of_doctype (self, doctype)” to get parentfield name from db. Please provide me an example.

Are you planning to make it open source?

What do you mean by parent? Is it a Link to a different document?

Regards

I am just doing it for learning.
If it is successfully completed, I will make it open source.