Even if you buy from a legit dealer how do they know? My bike came from John Lee where it was traded in. How can they check if there is no database to check?
Unless we all record our VIN, frame and engine numbers and then lodge them with the police if there is a theft there is no method to check. In the UK like Lineaway's post above the different police forces have different databases, so a bike stolen in Yorkshire can be sold in Essex and almost certainly the frame number is not on the local police database. Besides how many of us keep that record? (No, I have not before you all ask)