An interline flight is an agreement between airlines to coordinate passengers with an itinerary that uses multiple airlines, without having to check in again or deal with their baggage at the stopover. The interline relationship is between different legs that can connect.
A codeshare agreement is where airlines operate flights on behalf of another airline, using their flight code. The codeshare relationship is actually on a leg between one operating airline and one or multiple marketing airlines.
A codeshare agreement usually requires an interline agreement so that the marketing carrier can publish a connection with one leg operated by itself and another operated by its codeshare and interline partners.