What conditions favour nucleophilic substitution?
SN2 - polar Aprotic ( no O-H or N-H bonds)
SN1 - polar Protic (at least one O-H or N-H bonds)
2.) Substrate ( Leaving group (LG) attached to the carbon is...)
SN2 - methyl > primary > secondary (you want the LG to be less crowded)
SN1 - tertiary > secondary ( you want the LG to be more crowded)
Side Note :
SN2 - Watch out of the steric hindrance blocking the nucleophile.
SN1 - Stabilizing the carbocation formed.
SN2 - Inversion ( you do a backside attack, since LG is blocking the frontside)
SN1 - Racemization
Substitution and elimination usually compete and are both formed in the product. However, one will be the major and the other will be the minor product. It is confusing at first but practice makes perfect. Answer the exercises from the book over and over again and it'll make sense.