I am working on a certain application. Its basic structure is as follows:
- a database
- a web interface to control the whole system
- a number of client applications on remote machines
The clients poll the database at regular intervals, to check if there are any tasks to perform. A task is:
- A formal name of the task (a string), for example "run-regression-test"
- A number of arguments. For simplicity, let's assume, that those are strings. There is no need to support more, than, say, ten arguments.
If the client retrieves a task, it parses the name and the arguments and performs certain actions.
Since all of the state information is stored in the database, the tasks must be stored there as well. What I really don't know, is how to implement this as cleanly as possible. Every solution I can come up with seems almost like an anti-pattern. One could store it in a single table like this:
create table tasks (
id int not null auto increment primary key,
name varchar(255),
arg1 varchar(255),
arg2 varchar(255),
...
)
I also thought of doing it in using two tables:
create table tasks (
id int not null auto_increment primary key,
name varchar(255)
)
create table task_args (
id int not null auto_increment primary key,
task_id int,
arg varchar(255)
)
This is a bit more flexible and easy to implement as well. However, it is impossible to tell which argument out of a number of argumens is first, which is second, etc (can be fixed by adding a "sequence" column to the task_args table).
I am sure there are better and cleaner ways to do what I want. Perhaps someone with better skills in app-design can give me some inspiration.
Thanks in advance.