As others have pointed out, Mandarin is one dialect of Chinese. It is the dialect spoken in Beijing. The written language is the same, but the spoken language is different depending on what part of China you are in. For instance, in Hong Kong, most Chinese typically speak Cantonese, though I am sure that many know both dialects. There are several other dialects as well, but what unites them is a common writing system.
I just wanted to add that you don't need to know 40,000 characters to read a typical newspaper. The actual number used on a daily basis is much smaller. According to the wikipedia article on the Chinese language, a well-educated Chinese speaker recognizes approximately 6,000-7,000 characters, but only about 3,000 characters are necessary to read a newspaper. The official government standard regarding literacy as a knowledge of 2,000 characters, though this is only functional literacy. As far as the 40,000 characters goes, this is only in a large, unabridged dictionary which would include rare and obscure characters. Less than a quarter of these characters are now used. In addition, learning the characters is made easier by the fact that they are not pictograms, but they are made up of components relating to both meaning and sound. You'll see many of the same basic parts or "radicals" in many different words.
Also, the amount of sounds in Mandarin Chinese is much smaller than the amount of characters. This is because a word can mean different things in a different context, so that part of the language is actually easier. What is difficult in the language is mastering the tones. I took a one credit class in addition to my regular Chinese class that helped me to master this system. It's not hard, but it does take time, as do any new languages.
EDIT--
Ok, well someone thumbs-downed me on my response. This might help clarify things in regard to the writing and its relationship to Mandarin. I didn't mean to imply that it had no relation to Mandarin at all.
From the wikipedia article on Written Chinese:
"Chinese dialects vary not only by pronunciation, but also, to a lesser extent, vocabulary and grammar.[36] Modern written Chinese, which replaced Classical Chinese as the written standard as an indirect result of the May Fourth Movement of 1919, is not technically bound to any single dialect; however, it most nearly represents the vocabulary and syntax of Mandarin, by far the most widespread Chinese dialect in terms of both geographical area and number of speakers.[37] This version of written Chinese is called Vernacular Chinese, or 白話/白话 báihuà (literally, "plain speech").[38] Despite its ties to the dominant Mandarin dialect, Vernacular Chinese also permits some communication between people of different dialects, limited by the fact that Vernacular Chinese expressions are often ungrammatical or unidiomatic in non-Mandarin dialects. This role may not differ substantially from the role of other lingue franche, such as Latin: For those trained in written Chinese, it serves as a common medium; for those untrained in it, the graphic nature of the characters is in general no aid to common understanding (characters such as "one" notwithstanding).[39] In this regard, Chinese characters may be considered a large and inefficient phonetic script.[40] However, Ghil'ad Zuckermann’s exploration of phono-semantic matching in Standard Mandarin concludes that the Chinese writing system is multifunctional, conveying both semantic and phonetic content.[41]
"The variation in vocabulary among dialects has also led to the informal use of "dialectal characters", as well as standard characters that are nevertheless considered archaic by today's standards.[42] Cantonese is unique among non-Mandarin regional languages in having a written colloquial standard, used in Hong Kong and overseas, with a large number of unofficial characters for words particular to this dialect.[43] Written colloquial Cantonese has become quite popular in online chat rooms and instant messaging, although for formal written communications Cantonese speakers still normally use Vernacular Chinese.[44] To a lesser degree Hokkien is used in a similar way in Taiwan and elsewhere, although it lacks the level of standardisation seen in Cantonese. However, the Ministry of Education of the Republic of China is currently releasing a standard character set for Hokkien, which is to be taught in schools and promoted amongst the general population."
(from the wikipedia article on "Written Chinese")
http://en.wikipedia.org/wiki/Chinese_written_language
I hope that clarifies things.