0

What is the best way to store specific data and information in a web application?

The sorts of information I am talking about is one off, one time, stand-alone values. Mostly values that can be altered using an admin panel.

some examples of data I want to store:

  • Site owner: description of job, who they are and what they do
  • Toggles: true of false data. For example: to determine whether a section of the site is active; Essentially settings the owner of the site could manage
  • colour schemes (as in the owner will set what the user will see)
  • site logo (path to)

Obviously this data needs to be stored permanently i.e. if the web site is restarted the data still exists.

As far as I can see, my options are either: a Database or just a text file.

The conclusion that I came to was that using a database (row(col1 = data-type, col2 = value)), to me, seemed overkill and also constrained, but clean. Using a file would probably easier, but possibly messy and extra work to build a system to handle that file.

One advantage I see of using a file is that I can manually change values without running the site or a database manager (phpmyadmin). However, the site is going to be using a database anyway, and so part of me thinks that I should just use what is there instead of building a file manager.

ICP
  • 97
  • 10

2 Answers2

1

I believe what you are asking is "Is it considered appropriate to create a database table when there is only one field?" Or, "Is it okay for a field in the database to be a very small piece of information, like YES or NO?" The answer to both is yes.

It first sounded like you weren't aware of databases. You say you have MySQL. If you're not familiar enough with the purpose of a database, it's worth learning. They are not hard to use.

This explains basic parts of a database: https://en.wikipedia.org/wiki/Data_hierarchy

This explains the process of "normalizing" a database when designing. It helps make sure things are set up in the logical way. https://en.wikipedia.org/wiki/Database_normalization

gboone
  • 93
  • 10
0

Use SQLite => for SQLite you don't need any database engine just a library. It's portable and you can use SQL to query it. Read it

Rafay Hassan
  • 740
  • 8
  • 23
  • Would this be used along side mySQL? or Instead of? – ICP Dec 07 '18 at 16:25
  • @ICP It won't be used with MySQL. You just need a library to work with it. that's it. It's a file that will lie in your code. You don't need to connect to any DB server. – Rafay Hassan Dec 07 '18 at 16:49
  • No, I mean would this make sense to use it if I would also be using mySQL. – ICP Dec 07 '18 at 18:48
  • Yes, you can use MySQL and SQLite in the same application at the same time both have their advantages and disadvantages. It depends on the usage which one you should use. I think your case SQLite is the best option. Read the following links [Article talking about advantages and usage](https://dzone.com/articles/sqlite-vs-mysql) [stack answers talking about performance of SQLite and MySQL](https://stackoverflow.com/questions/29452110/sqlite-faster-than-mysql) – Rafay Hassan Dec 08 '18 at 12:20