When you represent a periodic function by a Fourier series you do pretty much the same thing: you represent it by sines instead of δ-functions.
For your specific example, you have two alternate resolutions of the identity/ completeness relations, $$ 1\!\!1= \int\!\! dx ~|x\rangle\langle x| \\ 1\!\!1= \sum_a |a\rangle \langle a| $$ where, importantly, $\langle a|x \rangle = \phi_a^* (x)$, your change of basis "matrix".
You then have $$ \psi(x)=\langle x|\psi\rangle = \sum_a \langle x|a\rangle \langle a|\psi\rangle = \sum_a \phi_a(x) ~~\psi_a, ~~\hbox{where}\\ \psi_a=\langle a|\psi\rangle= \int\!\! dx ~ \phi^*_a(x)~ \psi(x), $$ by the above completeness relation. In your expression, you used the same x as a variable, and as a dummy integration variable in your inner product--a disastrous practice.
It is crucial to test-drive this equivalence with the Hermite functions $\psi_n(x)=\langle x|n\rangle$, where the discrete index is the natural number identifying the quantum oscillator energy level, if you have not already done so.
Useful link as per your comment.