A codeshare is an agreement between two or more airlines to share the same flight equipment, though with different flight numbers.
A ticket may be purchased on one airline, but the plane’s metal may be from a different airline. A way for one carrier to partner up with another airline to increase the places that they fly to. Passengers are allowed to earn rewards in whichever frequent flier program they choose (which is codesharing the flight), no matter the purchasing carrier.
Example: A flight from JFK to San Salvador (SAL) was in the past available to purchase via Delta (Flight #DL 1235). The actual flight and crew metal were from TACA airlines (Flight # TA 636), which had also offered tickets to the flight.