In this paper we present a new compressed and self-indexed data structure that we call Interleaved k2-tree (ik2-tree), designed to compactly represent and efficiently query general ternary relations. The ik2-tree is an evolution of an existing data structure, the k2-tree, initially designed to represent Web graphs and later applied to other domains. The ik2-tree is able to extend the k2-tree to represent a ternary relation, based on the idea of decomposing it into a collection of binary relations but providing indexing capabilities in all the three dimensions. We present different ways to use ik2-tree to model different types of ternary relations using as reference two typical domains: RDF and Temporal Graphs. We also experimentally evaluate our representations comparing them in space usage and performace with other solutions of the state of the art.