IF you have more than one IDE device, here are the rules for how to connect them all. It is easy to distinguish these things. Optical drives can be either SATA or IDE. IDE has two major connectors on the back with pins recessed in a surrounding shroud. One has 4 round pins in a straight line, and that's for power from a 4-pin Molex output from the PSU. The other has two rows of 20 pins each with one pin missing. That is for the data communication ribbon cable connection to the mobo IDE port. A SATA device, on the other hand, has two much smaller connectors, each looking like an edge of a printed circuit board that has metal contacts on its surfaces. The wider one is for power from a different PSU output, and the narrower one is for the SATA data cable. You can connect only ONE device to any mobo SATA port.
Any mobo IDE port can support up to TWO IDE devices using the right ribbon cable. IF you have more than two IDE devices, you need more than one IDE port on the mobo. Each mobo port and cable set needs a way to distinguish which device is which, and that is done by setting jumpers on a block of 8 pins (two rows of 4) on the back of the device. There is NO "universal" way to set these, so use the diagram printed on that device.
For EACH set of port / cable / devices you need to set them up as follows. The cable has three connectors on it normally. The BLUE one on one end goes to the mobo IDE port. The BLACK one on the other end must go to the device that you designate as the port's MASTER by setting its jumpers. SOME devices have slightly different jumper settings for a Master with No Slave present, or with a Slave. IF you connect a second device to this cable, it MUST be set to the SLAVE setting and plugged into the middle GREY connector.
If you have both a HDD and an optical drive on one cable, it is recommended that the HDD be set and connected as the Master device for that port / cable, and the optical drive be the Slave. This is just a precaution because SOME older optical units could not function properly as Masters.
Understand that the "Master" and "Slave" labels apply only to that one mobo IDE port. There is no Master of the entire computer. In fact, there is no Master of all of the IDE ports.