Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Assume a website with 250 million active users.

I add a new feature to the website. Once a user visits I want to use a short tutorial to teach them how to use said feature. I only want them to complete the tutorial once (or actively click it away).

What is the smart way to code the verification check for this? How do I track the progress in the database? Having a separate table with like NewTutorial_completed = 1 for user_id = 21312315 would just snowball. It also feels intuitively bad to check for every one-time event for every user on every page view.

While writing the question I got one idea, to have a separate event log that is checked periodically for any new action the user need to see or perform. I push events to this log and once they are completed they are removed from the log. No need to store NewTutorial_completed = 1-type variables this way.

I am sure this is a common problem. I would appreciate any input on what best practice is.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

A whole new database table would certainly be overkill. It is fairly common practice to use add a column to the exist user table for something like this. Presumably you have a user object that gets loaded from the appropriate row of this table and that object could be extended as well.

Doing that implementation requires:

  • A database migration to add the column
  • Addition of the field to the user object
  • Changes to the CRUD code that loads and saves these objects from the database (hopefully you have a good ORM layer that makes this easier)

Recently I have started using no schema storage for items like this. Take a page out of the NoSQL playbook. I create one column in the user table that stores many such pieces of data. The column is a TEXT column. The field is populated with a JSON representing many such pieces of information about the user. Loading and storing info to this column is pretty easy with object to JSON mapping libraries such as Google's Gson library.

Once this column is in place, tracking new items about the user is as simple as writing the object code. No database or CRUD changes are required.

The disadvantage of this approach is that it is hard to query these values. It is harder, for example, to query the database for a list of users that have taken the tutorial.

share|improve this answer
    
json in a database ew. Not to mention text 1 takes up far more space than a bit and isn't queryable –  JamesRyan Nov 14 '13 at 16:01
    
Somewhat larger, not available for queries, but very convenient and much easier to code. I would only recommend this for "display only" type data that doesn't need to be queried, but for which the schema would have to change frequently. –  Stephen Ostermiller Nov 14 '13 at 16:07
    
Yes it comes down to whether you prefer a schema that is easier to use or easier to change. However less well defined also means easier to break. –  JamesRyan Nov 14 '13 at 16:30
    
Yes, having adding unfinished "tasks" to the user object is absolutely a good idea, thanks for your input Stephen! –  Mattis Nov 18 '13 at 14:13

Reading this the first thing that comes to mind is a cookie or session variable. You might implement something such as your NewTutorial_completed and have it read it only once when the cookie or session variable isn't set, such as upon a login.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.