Every ship in Starfleet has a registry number which is used to identify it in computer records and the like. Most such numbers begin with the prefix NCC, which stands for Naval Commission Contract. In other words, a ship's registry number derives from the number assigned to the paperwork which authorized its construction. Experimental or prototype vessels may instead have the prefix NX (Naval Experimental). Civilian vessels use a plethora of designations.
A ship's registry often indicates the approximate timeframe during which it was built and commissioned (see accompanying table). Due to the vagaries of the Starfleet bureaucracy, snags in the contracting and construction process, ships named to honor earlier ships, and other factors, a number may be assigned (or re-assigned) which, to outside observers, seems to contradict this system. A proper search of the relevant Starfleet records will always unearth the precise information about when a ship or its class was constructed.
Starfleet Registry Table