I want to limit the datatype value that can be stored within a field to a specific range of integer values: [0,10].
On user input within a PHP script I validate and
You can create a table of allowed vote values and add a foreign key in your votes table, so when you try to insert a vote with user_vote value other than existing in your allowed_votes table you get a constraint fail error:
CREATE TABLE allowed_votes (
vote_rank TINYINT UNSIGNED NOT NULL,
PRIMARY KEY (vote_rank)
) ENGINE = InnoDB;
INSERT INTO allowed_votes( vote_rank ) VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
ALTER TABLE votes
ADD FOREIGN KEY (user_vote) REFERENCES allowed_votes (vote_rank);