We treat the problem of designing low-density parity-check (LDPC) codes to approach the capacity of relay channels. We consider an efficient analysis framework that decouples the factor graph (FG) of a B-block transmission into successive partial FGs, each of which denotes a two-block transmission. We develop design methods to find the optimum code ensemble for the partial FG. In particular, we formulate the relay operations and the destination operations as equivalent virtual MISO and MIMO systems, and employ a binary symmetric channel (BSC) model for the relay node output. For AWGN channels, we further develop a Gaussian approximation for the detector output at the destination node. Jointly treating the relay and the destination, we analyze the performance of the LDPC-coded relay system using the extrinsic mutual information transfer(EXIT) chart technique. Furthermore, differential evolution is employed to search for the optimum code ensemble. Our results show that the optimized codes always outperform the regular LDPC codes with a significant gain; in the AWGN case, when Protocol-II is employed and the relay is close to the source, the optimized code performs within 0.1dB to the capacity bound.