We've already alluded to the underlying concept for RPM's dependency processing.
Packages advertise what capabilities they require.
By simply checking these two types of information, many possible problems can be avoided. For example, if a package requires a capability that is not provided by any already-installed package, that package cannot be installed and expected to work properly. On the other hand, if a package is to be erased, but its capabilities are required by other installed packages, then it cannot be erased without causing other packages to fail. As you might imagine, it's not quite that simple. But adding dependency information can be easy.