Right way of developing dynamic inventory?

Is there a guide for developing dynamic inventory? (beyond the one already given here)

What I’m looking for is more constraints/conditions to abide by. What are the rules to follow to make sure the outputs are correct?

For example:

I have a dynamic inventory based on a database, and it has 2 tables, one for ansible groups, and one for hosts.

  • If I add a host and a group at the same time, I’d add it in both tables. What happens if I remove it only from the host table? Does that break anything?
  • What happens when a host is not specified to a group, and I’m not returning a “ungrouped” group?
  • If I have a “_meta” field when i return for “–list” option, do I even need “–host” option?

I wanted to dive deeper on this topic, but the documentation seemed limited. Would appreciate anyone directing me to resources.