The longest carbon chain is the parent chain containing the principal functional group.
The principle functional group is always given the highest priority, lowest number (1 before 2, 3, 4...), and assigned as a suffix while writing the nomenclature. Therefore, the numbering of the parent chain always starts from the principal functional group.
If an organic compound has more than one functional group, the functional groups are numbered according to their priority order. The other functional groups in the molecule, other than the principal functional group, are treated as substituents and assigned as prefixes. In case of the presence of double/triple bonds, the priority order is-
Principal functional group > double bond > triple bond > substituents
Examples:
1) IUPAC name- Pentan-2-one
The suffix in the IUPAC name Pentan-2-one is -one, attributed to the Ketone functional group (RCOR). No other prefixes are identified, so the principal functional group is a ketone, and the parent alkyl chain is pentane (5-carbon).
The structure is-
2) IUPAC name- 5-oxohexanoic acid
The suffix in the IUPAC name is -oic acid, assigned by IUPAC to the Carboxylic Acid functional group (R-COOH). Therefore, the carboxylic acid is the principal functional group.
The IUPAC name 5-oxohexanoic acid has a prefix -oxo, at the 5th position of the parent hexane chain, used for representing the ketone functional group. The ketone functional group is the secondary functional group.
Therefore, the final structure of the molecule is-
3) IUPAC name- 6-bromo-5-chloro-4-oxohept-2-enoic acid
The suffix in the name 6-bromo-5-chloro-4-oxohept-2-enoic acid is enoic acid.
The principal functional group is -oic acid (carboxylic acid, -COOH), and the next priority is the -ene (double bond, C=C). Combined ene+ oic acid gives enoic acid.
Prefixes are- bromo, chloro and oxo as the substituent functional groups.
The halogens are named alphabetically (b before c) though the chloro is at number 5 and bromo at number 6.
The secondary functional group is oxo, assigned to the ketone (RCOR). The parent alkane chain is 7-carbon heptane.
The final structure of the compound is-
Related Reading- What is the priority order in polyfunctional compounds while assigning nomenclature?