grateful grateful - 5 months ago 7
MySQL Question

Where to save a single value on server

I am creating an application with a click to call button on an html page.

There will be one person manning the phone. I want this person to be able to set a variable with a boolian value on my server: 1 is available, 0 is unavailable.

I could create a single field SQL table
but this feels like overkill, or I could read and write to a text file containing just one character.

What is the most correct way to store a single value?


I know it seems like overkill to use a small database table for this.

If your application already uses a database, this is by far the best way to proceed. Your database technology has all kinds of support for storing data so it doesn't get lost. But, don't stand up a database and organize your application to use it just for this one data point; a file will be easier in that case.

(WordPress does something similar; it uses a table called wp_options containing a lot of one-off settings values.)

I suggest your table contain two columns (or maybe more), agent_id and available. Then, if you happen to add another person taking telephone calls, your app will be ready to handle that growth. Your current person can have agent_id = 0.