Enter tags.

I created a version two of the database (although it is not actually used in the script, yet, only manually) which includes tags and tag applications. I used a trigger that runs after a successful delete which deletes records of the tag application. That is actually either because of the trigger or the foreign key dependency. Not too sure.

I also created a method that deletes either of the two tables that are created in the upgrade to two. Basically, I had it error out on the second delete statement because of a type, but it had already done the first delete statement. The next time it ran, it errored out because the first statement had completed so there was not a table to delete. I wrapped it in tries because I expect them to be there, but there is a chance they are not.

I finally added methods to interact with tags to my tag interface. Basically everything from getting todo items with the tags to adding, removing, and deleting tags.

I did some basic testing to make sure the trigger statement worked as expected, it did to the basic test. I should probably write a couple of test scripts that run through all of the different functions and how to test them.

I thought this was going to be a no-zero day thing, but it has not due to many reasons. I am still trying to make that a thing, but I am not sure how often I may post depending on the level of home work any new real life job would require.  Yeah, also, I like being with my wife a lot, so I choose her over posting here mostly.

Till next time! (Likely tonight, honestly 🙂 )


SQL statements: from mild to hot.

Recently I have been asked a couple of SQL questions, so I decided to brush up on some of it.  I was going to talk about mild being things like “CREATE TABLE” or “INSERT INTO”, medium being joins, then hot being this other thing.

I don’t have patience for all of that, so lets get straight into the HOT.

Did you know you can create TRIGGERs in SQLite?  Yeah, you can create snippets of SQL that run before or after specified events to specified data. I know this because originally I was interested in adding a last modified column to my data, but could not figure out a way short of me coding it into all of my statements. Not any more!  Here is an example of creating a table which will update last modified column, if I understand correctly.

Yeah, I haven’t tested it yet, I found that idea after I commited for the last time tonight.  (Maybe/probably) Anyway, hasta la pasta!  Be safe and watch for ninjas!