one flight number (regardless of change of equpment, etc) needs only one ticket (but you will eventually at check-in get two boarding passes).
miles: calculated for a direct flight only (but you only get that smaller mileage credit too to your frequent flier program).
segments: the whole flight, as long as it is under the same flight number, only counts as one segment, and the place of change of equipment doesn't count at all (as if you never were there).