When working on writing melodies for my original compositions, my standard approach is to examine the chord progression in order to determine which scales or modes would best apply. A mode is the notes of scale, such as the major scale, oriented around a different root note and chord; Modes offer great flexibility in terms of the way they relate to a set of chords within relative keys.