Before I ask the question, I just want to admit that I'm a beginner at MySQL. I've searched for the solution in various places but had no luck. I'm working on a project where there are a particular number of books in the database and all the users that are signed up in the website can access this list of books( these books are common to all users). And the logged in user can put a check-mark beside the listed book if he completes reading it.
I've created tables users
, books
and user_books
. The user_books
table contains userid(references users table) and bookid(references books table) columns with an isComplete boolean column where the actual "check-marks" are stored.
Now what I'm actually looking for is a way to insert the userid(repeated with every book) and the whole column of bookid for each user into the user_books
table. i.e., if the books
table has books a, b and c and if a user John registers into the website, the user_books
table should be updated with ('John', 'a'), ('John', 'b') and ('John', 'c'). This trigger should be applied immediately after the user registers into the website.
Or if there is any other way to achieve this "to-do" functionality for every user and every book, please do mention that.