The problem with Hello World is that it doesn't match any real problem, and certainly not one that VoltDB is designed to solve. However, it is not too hard to think of a practical problem where saying hello could be useful.
Let's assume we run a system (a website, for example) where users register and log in to use services. We want to acknowledge when a user logs in by saying hello. Let's further assume that our system is global in nature. It would be nice if we could say hello in the user's native language.
To support our new user sign in process, we need to store the different ways of saying hello in each language and we need to record the native language of the user. Then, when they sign in, we can retrieve their name and the appropriate word for hello.
This means we need two tables, one for the word "hello" in different languages and one for the users. We can reuse the HELLOWORLD table from our original application for the first table. But we need to add a table for user data, including a unique identifier, the user's name, and their language. Often, the best and easiest unique identifier for an online account is the user's email address. So that is what we will use. Our schema now looks like this:
CREATE TABLE HELLOWORLD ( HELLO VARCHAR(15), WORLD VARCHAR(15), DIALECT VARCHAR(15) NOT NULL, PRIMARY KEY (DIALECT) ); CREATE TABLE USERACCOUNT ( EMAIL VARCHAR(128) UNIQUE NOT NULL, FIRSTNAME VARCHAR(15), LASTNAME VARCHAR(15), LASTLOGIN TIMESTAMP, DIALECT VARCHAR(15) NOT NULL, PRIMARY KEY (EMAIL) );
Oh, by the way, now that you know how to write a basic VoltDB
application, you don't need to type in the sample code yourself anymore.
You can concentrate on understanding the nuances that make VoltDB
applications exceptional. The complete sources for the updated Hello World
example are available in the
doc/tutorials/helloworldrevisited
subfolder when you
install the VoltDB software.