As one commenter pointed out: Compare basenames of the file.
Downside of this: Your camera will wrap filenames at 10,000. (Most only use 4 digits.) You may have the option to set a prefix, but if you forget to change it in time you can have a problem.
If your software will recursively show sub directories contents when you click on a folder, then sort the pictures by timestamp. Since the raw and jpeg have the same time stamp they will be adjacent. Caution: May not always be in the same order. Eg. Pix with the same timestamp can be either jpeg first or raw first.
Another possibility is to change names on import to some version of the datastamp. E.g. 2018-10-02_10-51-16. There are two downsides to this: In shoot-as-fast-as-possible-and-hope-to-catch-the-wow-shot mode you can get several frames with the same time stamp. Your import software may be clever enough to put a,b,c... after them, or if really clever will pull the hundredths of a second field out of exif and use that.
If you have multiple cameras, you can get timestamp collisions. (Most of us have at least 2 AND a phone...)
This method can hoop you with scanned images.
Anyway give them a base name and the suffixes will tell them apart.
I have a friend who renames images according to what is in them. This makes it harder. If you do it at different times, you might have totally different names. E.g. Alastair and Beth McKay vs Beth and Alastair McKay.
Ok: The IPTC field Title is actually designated for a unique file ID. Use it. You will need to script this in some way. Too much depends on your software for me to advise -- Hint: Look at ImageMagick. So now 2018-{ddddd}[J|R] is your unique ID where ddddd is a 5 digit ID and J or R says jpeg or raw file.