At the most basic level computers deal with numbers, and so when connecting computers it makes sense to have each computer identify itself with a number. There are various schemes for doing this, but at present the most common one is the IP protocol. Humans however are better with names, so we have developed ways to map a name onto a numeric address.
When the internet was first getting started all of the computers connected to it were listed in a single file, the hosts file. This file held a list of a computer's name and the numeric address it could be found at. Each time a new computer was added its name had to be added to this file and the new file would have to be distrubuted to all of the other computers on the internet. A new hosts file would be created every few months and sent out to the various organizations that were connected to the internet so that they could update their copies of the file. As the number of computers connected continued to grow this became impractical, as the hosts file was becoming too big, and the task of maintaining it too difficult
DNS was created in the 1980s as a solution to this problem. The idea is that each organization is responsible for the records related to its computers. This means that each group only has to maintain the records for their own computers, and there isn't a need to send a huge hosts file between all the computers on connected to the internet.
DNS works as a hierarchy. The hierarchy can be seen in the domain names, if you read them right-to-left. At the right is the top level domain (tld). Tld's are shared by multiple organizations and individuals. Tlds are the .com, .net. .org, etc. part of the domain name that people are familiar with. The allowed tlds are determined by ICANN, the Internet Corporation for Assigned Names and Numbers. Within the tlds individuals and organization can register second level domains. This is done by registering the domain with a registrar. Levels are separated by a '.', so for spry.com, spry would be the second level domain, and com would be the tld. The owner of a second level domain can create third level domains if he wishes (eg www.spry.com, or mail.spry.com). It is possible to create fourth, fifth, ..., level domains, which are referred to as sub domains. However sub domains are typically used to reflect a hierarchy in the real world (so you might see helium.dev.example.com to represent a computer named helium used in the development team at example.com), and so aren't necessarily needed for organizations with a fairly simple structure.
When a computer tries to resolve a hostname, it will first check its DNS cache. If it has recently looked up the hostname, then the hostname will likely be in it's DNS cache. This saves the computer from having to do a search for the name a second time, and it can use the IP address it has stored. If the hostname isn't in the computer's cache, then it will have to search for the hostname using DNS. The computer will start the search at the root nameservers. These are nameservers that handle the top level domains. As the root nameservers only handle the top level domains, when they receive a request for a domain, they see which nameservers have been delegated the domain. Delegation is the process by which sub domains are assigned to different nameservers. When you register a domain name, that domain will be added to the root nameservers, along with records saying which nameservers are responsible for that domain. This is how other computers know which nameservers to use for your domain. Once the root nameservers tell the computer where to find the nameservers for the domain, the computer will resend its request, this time to the nameservers for that specific domain. So each new query will follow the following outline
This is why DNS requires that records in different places all match up. The registrar's records have to point to the correct nameservers, and those nameservers have to be correctly configured to answer for the domain, and have the correct records for the domain.* Check cache for record. If not found check root nameservers.
* Check root nameservers. If the domain is registered they will point to the domain's nameservers.
* Check the domain's nameservers. These will return the correct record, or the sub domain's nameservers if there has been further delegation.