A lot will depend on the country you live in and the wiring colours (colors) used for the original installation and the electrical wiring standards & regulations where you live.
Here's a simple picture...
http://www.davesdiytips.com/wp-content/uploads/2009/01/daves-ceiling-rose-new-colours.jpg
A & B are power cables in and out - C is the cable to the switch
Notice that no live (hot) wire runs directly to the lamp.
The lamp itself connects to 1 & 8
Terminals 3, 4 & 5 are the live wires
Terminals 6 & 7 are Neutral wires
The wire that catches out most people is the wire to Terminal 2.
The drawing shows it to be brown but in most existing installations it will look like a Neutral wire and the temptation is to join it with the other Neutral wires of the same colour - which you should not do.
Terminal 2 carries Switched Live - the wire that actually turns the lamp on and off - and it should ideally be identified with a coloured sleeve (Red or Brown in the UK) to indicate that it could be lethal. You must identify which of the wires is actually Switched Live to make things work properly or at all.
Lord Finchley tried to mend the Electric Light
Himself. It struck him dead: And serve him right!
It is the business of the wealthy man
To give employment to the artisan.
Take care...
Peccavi
April 2009