I will guess feed into lamp, feed out to next lamp, and switch wire. And yes all required. The blacks or in newer installations the blues cause problems if not carefully noted likely two will be neutral and one will be switched feed to lamp. Also likely the reds or in newer installations browns connect together but do not connect to lamp.
There are diagrams in projects section which should help. Do make careful notes before disconnecting anything photos are good idea too as if you get neutral and switch wire mixed up then likely you are going to have to get electrician in to sort them out.
DIY how to tutorial projects and guides - Did you know we have a DIY Projects section? Well, if no, then we certainly do! Within this area of our site have literally hundreds of how-to guides and tutorials that cover a huge range of home improvement tasks. Each page also comes with pictures and a video to make completing those jobs even easier!