That’s a great question!
I think it depends how you define that “relation”. You may be familiar with some of these methods, but please check them out if you’re not! You could do something like an encoder decoder network, and then compare the encodings with a distance similarity (like cosine distance). But you could also try that with a method like PCA.
Encoding and PCA, in a simplified sense, take your records and convert them to a few numbers, so you can then just compare the numbers with some distance formula. There are some great tutorials on using Keras for encoders, so please check them out!
Scikit-learn has some good documentation on PCA (principal component analysis), and the tensorflow and keras site have some good code examples, including some on encoders (usually with images, but it’s the same concept).
I hope this helps!