Alvaro Martín Gómez A.
TalkBass' resident Bongo + cowbell player
If you're asking what notes you can play, obviously you should not play an F natural against a D major chord. Unless you're doing something experimentally noisy, of course.
Not necessarily. Blues-based music heavily relies on a practice known as broken third, which consists of playing minor melodies over major chords. What really happens there is that, since the three chords typically used in a blues chord progression are all dominant (C7 - F7 - G7 for a blues in C) it makes very easy to superimpose almost whatever you like over them because dominant harmonies are very flexible and friendly (the natural overtones succession has to do with that). So, what really happens in a "major" tune with a "minor" melody is a dominant seventh chord with an augmented ninth added. For the D Major example, it would be a D - F# - A - C - E# being the E sharp the augmented ninth of the chord, which sounds the same as the minor third (F natural).
A simple and very well known example among so many would be "Jailhouse Rock". If you play it in D Major, the singer must hit an F natural (technically an E sharp) every time the D Major chord is being played. A couple of years ago someone (from these latitudes) recorded a medley of classic rock and roll tunes and sung all the songs with a "major" character, which absolutely kills them (and made me want to kill whoever did that).