step # 1 insert an entry in the wp_posts table for your certification
INSERT INTO wp_posts (post_type, guid, post_status, post_mime_type,post_parent) VALUES ('attachment', '".$filename."', 'inherit', 'image/jpeg',".$parentpostid.");
$ filname = url of the image you want to use as a thumbnail, for example. http://yourdomain.com/wp-content/uploads/2014/09/thumbnail.jpg
$ parentpostid = post_id of the message you want to add to your thumbnail.
step # 2 create a meta-post on wp_postmeta for your attachment
INSERT INTO wp_postmeta (meta_value, meta_key, post_id) VALUES ('".$filename."', '_wp_attached_file',".$attachmentid.");
$ filename = the file name of your file. e.ge. 2014/09 / thumbnail.jpg $ attachmentid = post_id of the attachment message created in step # 1
step # 3 create a message meta-record to identify the attachment post as a thumbnail for the message you are attaching a thumbnail to.
INSERT INTO wp_postmeta (meta_value, meta_key, post_id) VALUES (".$attachmentid.", '_thumbnail_id',".$parentpostid.");
$ parentpostid = post_id of the message to which you want to attach your sketch.
$ attachmentid = post_id of the attachment message created in step # 1