How to create and work with custom data / tables (i.e., for arbitrary data)?

WordPress has a pretty flexible way of handling custom data, and it stores it in a table called wp_postmeta (assuming default wp_ prefix). The only catch is that it assumes that it will somehow be related to a certain post, which I’m not sure you actually want to do.

It’s very simple to use (see here for more info):

// Add a custom data (i.e. textfield of value '5') for post ID = 1
update_post_meta(1, 'my_textfield', 5);

// Return an array which contains 'my_textfield' values from post ID = 1
get_post_meta(1, 'my_textfield', true);

If the information is not related to a post, but rather to a user, you can also take advantage of the wp_usermeta table. The idea is the same (see here for more):

// Add a custom data (i.e. textfield of value '5') for to user 1
update_user_meta(1, 'my_textfield', 5);

// Return an array which contains 'my_textfield' values for user 1
get_user_meta(1, 'my_textfield', true);

Creating a custom table should be a last resort, and only used when the custom information you want to store has more than one value (i.e. you need to know the number chosen by the user, the time it was recorded, the IP of that user, etc). In that case, you’ll need to code your own functions to add values to that table, not to mention the PHP code which will create that table in the first place. It’s more complicated, anyone who’s done it before will attest that it’s a delicate affair and hard to debug, plus there’s no guarantee that it won’t break in future WordPress versions. Anyhow, if that’s what you need, this should get you going.

Hope it helps! Let us know how it goes.