Apple uses Gracenote for identification and tags. It is the industry standard.
http://support.apple.com/kb/HT3814
There are free and open implementations of the same thing as well. It hashes the track locations and lengths to create a 'fingerprint' for each CD. Then it looks up the hash in the database.