Discovery can identify and classify information about relationships between configuration items. This is relevant for both infrastructure configuration items and applications discovered. There are many relationships which are discovered and created out of box. Additionally, patterns and sensors can be updated if necessary in order to add more relationships.
Discovery relationships are generally created either by configuration in a pattern or via calls to DiscoveryFunctions.createRelationshipIfNotExists().
Steps required to create relationships via patterns can be seen in the following link:
Note: Patterns can also create relationships via calls to DiscoveryFunctions.createRelationshipIfNotExists() via "Pattern Designer > Pre Post Processing".
Sensors can create relationships by calling DiscoveryFunctions.createRelationshipIfNotExists().
The following snippet is from "Windows - Get IIS Information" sensor:
var gr = new GlideRecord("cmdb_ci_appl");
g_disco_functions.createRelationshipIfNotExists(gr, iisGr, "Depends on::Used by");