Answer the question
In order to leave comments, you need to log in
How to synchronize uploading data from an application to a remote MySQL server?
There is a table
CREATE TABLE t1(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
link CHAR(36) NOT NULL UNIQUE
);
CREATE FUNCTION insert_t1 (_link char(36)) RETURNS INT UNSIGNED
BEGIN
INSERT INTO t1(link) VALUE(_link);
RETURN LAST_INSERT_ID();
END
Answer the question
In order to leave comments, you need to log in
Insert through INSERT IGNORE, then there will be no duplication. Then do a SELECT on link and return the resulting id.
Generate a unique key on the client, receive from the server not an id, but a confirmation of the record. If it was not received, send the request again, but something like insert or select, and let the server return success if the record is found or tries to write.
For the key, make a special field in the table with UNIQUE INDEX.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question