If an sObject is a parent object, you can access the child relationship as well as the child sObject using the ChildRelationship object methods.
A ChildRelationship object is returned from the sObject describe result using the getChildRelationship method. For example:
Schema.DescribeSObjectResult describeresult = Account.SObjectType.getDescribe();//it gives Account object properties or describe results
List<Schema.ChildRelationship> lstchildrelationships =describeresult.getChildRelationships(); //It gives you all the childrelationships associated with the account.
To get relationship names from the above list
You can only use 100getChildRelationships method calls per Apex request.
The following table describes the methods available as part of the ChildRelationship object. None of the methods take an argument.
|getChildSObject||Schema.SObjectType||Returns the token of the child sObject on which there is a foreign key back to the parent sObject.|
|getField||Schema.SObjectField||Returns the token of the field that has a foreign key back to the parent sObject.|
|getRelationshipName||String||Returns the name of the relationship.|
|isCascadeDelete||Boolean||Returns true if the child object is deleted when the parent object is deleted, false otherwise.|
|isDeprecatedAndHidden||Boolean||Reserved for future use.|
|isRestrictedDelete||Boolean||Returns true if the parent object can't be deleted because it is referenced by a child object, false otherwise.|