A while ago I explained how you could tag articles (see this thread). Now you get a full working example. This code and the SQL script is also available on GitHub.
The attached MySQL dump needs to be imported into your database, and you must update the credentials in the code below. I think the code is short enough to be read without comments. If this is not the case, feel free to ask questions.