In computer science, canonical refers to the standard state or behavior of an attribute. It is conforming to an accepted rule or procedure. This term has been borrowed from mathematics, where it refers to concepts that are unique and/or natural. For example, the canonical way to organize a file system is as a hierarchy.
The term itself is an adjective derived from the word canon. The English word canon originates from a Greek word meaning a rule or measuring stick. In the early church, the canon was the officially chosen set of scriptures.
While what can be referred to as canonical is limitless, it is commonly used in a few settings:
Canonical in programming
In programming, canonical means according to the rules. Non-canonical means not according to the rules. The terms are used to distinguish whether a programming interface follows a particular standard or precedent or whether it departs from it.
Canonical in IP addressing
When referring to IP addressing, canonical refers to the authoritative host name stored in a DNS database that all IP address aliases resolve to. This is sometimes referred to as a CNAME record. A computer hosting a website must have an IP address in order to be connected to the World Wide Web. The DNS resolves the computer’s domain name to its IP address, but sometimes more than one domain name resolves to the same IP address, which is where the CNAME is useful. A machine can have an unlimited number of CNAME aliases, but a separate CNAME record must be in the database for each alias.
Canonical XML is a normal form of Extensible Markup Language (XML), which allows designers to create customized tags, enabling the definition, transmission, validation, and interpretation of data between applications and between organizations. Canonical XML is intended to allow relatively simple comparisons of pairs of XML documents for equivalence. It removes non-meaningful differences between the documents.
Canonical Ltd. is a UK-based, privately held computer software company founded by Mark Shuttleworth created to market commercial support and related services for Ubuntu and related projects.
A canonical model is a design pattern used to communicate between different data formats. It aims to present data entities and relationships in the simplest possible form to integrate processes across various systems and databases. Canonical models are typically used among enterprises to create and distribute a common definition of its entire data unit.