create table users (
id int primary key auto_increment
);
create table books (
id int primary key auto_increment,
created timestamp,
index(created)
);
create table read_books (
user_id int,
book_id int,
primary key (user_id, book_id)
);
select * from books
where UNIX_TIMESTAMP() - created < 600 and
not exists (
select book_id
from read_books
where read_books.book_id = books.id and read_books.user_id = :user_id
)
limit 1;