Any major chord (a major triad chord, major seventh chord, major ninth chord etc) consists only of the note names taken from the major scale, whose tonic is the same as the chord root. For instance, the C major seventh chord consists of the note names C, E, G and B, all of which belongs to the C major scale. This is how major chords get their names.
Figure: The C major scale and the C major seventh chord
Any minor chord consists only of the note names taken from the natural minor scale whose tonic is the same as the chord root. For instance, the C minor seventh chord consists of the note names C, Eb, G and Bb, all of which belongs to the C natural minor scale. This is how minor chords get their names.
Figure: The C natural minor scale and the C minor seventh chord
However, there is one important exception! As we saw earlier, the minor thirteenth chord does not contain the minor thirteenth over the chord root but the major thirteenth which does not belong to the natural minor scale. For instance, the C minor thirteenth chord contains the note name A and not Ab.
Any dominant chord (a dominant seventh chord, dominant ninth chord etc) consists only of the note names taken from the major scale whose dominant (the fifth scale degree) is the same as the chord root. For instance, the C dominant seventh chord consists of the note names C, E, G and Bb, all of which belongs to the F major scale. The dominant of the F major scale is C. This is how dominant chords get their names.
Figure: The F major scale and the C dominant seventh chord