The Batman: the Animated Series episode Zatanna introduced the idea that Bruce Wayne and Zatanna Zatara had known each other for some time, with Bruce learning escapology and such from her dad in his pre-Batman days. This idea was later incorporated into the regular Batman comics by Paul Dini himself, who expanded upon the idea to making the Zatara’s old family friends of the Waynes, including having Zatanna’s father be a friend of Bruce’s dad before they met their respective wives.
Interestingly, Young Justice changed this on its head, by making Zatanna closer to Dick Grayson’s age, and having those two become a couple at some point between seasons one and two. I suppose that the YJ versions of Dick and Zatanna getting together does make a degree of sense, beyond them having a similar sense of humour etc. in that they’re both the children of superheroes and, after Zatara is permanently possessed by the Dr Fate helmet, both effectively orphans as well.