There are a few steps involved, and a few decisions to make.
1) Uploading the base image.
2) Creating a thumbnail. Here you will want to keep both the original and the new thumbnail.
3) Saving to db. You have two choices here: move the images to a new folder and save the paths in the db or save the raw binary data. I can't say which is better for you.
3a) Saving the path.
*let me know which storage system you will be using, as well as which php wrappers, and one of us can assist you in the actual SQL code.
3b) Saving the bytes.
$data = file_get_contents('path/to/image.jpg');
$data = base64_encode($data);