In recent years, deep learning techniques have made remarkable strides in solving a variety of program understanding challenges. The successful application of these techniques to a given task depends heavily on how the source code is represented by the deep neural network. Designing a suitable representation for a newly created task involves many challenges. It is necessary, among other things, to understand the implementation of other functions or modules in a project that may be spread out across a large lexical area. In addition, determining which components and features to include in order to enrich the representation is a challenge. In this dissertation, the challenges of code representation are addressed by proposing to systematically represent programs as relational databases, introducing a graph walk mechanism to remove unrelated context from large relational graphs, and describing a language for specifying tasks and program analysis queries to tailor neural code-reasoning models. A detailed analysis shows the presented techniques are superior to state-of-the-art in a variety of aspects, such as performance, robustness, and interpretability.