views:

63

answers:

6

I am developing a web application about books. We all knows that books have different category. So, this category is basic on a sequence of number, for example, 200 = computer related, 800 = history. Each book is beyond to one category only.

Here is the question. I have a category list, it may expand in the future. For example, new technology is appear, and new category will be created. So, what should I store this category? In a database? or a simple XML file? Because it is not alter all the time, so, I am think will it become a waste to store in database? thz u.

+4  A: 

For me, the best decision is to use the database for storing. You don't know what changes will follow your project after time. Also if the data are into the database, you can easy update them and add related additional info. But it depends. You know better what kind of project you have and what technologies you are using.

Maybe XML is also a good choice. You can relatively easy to add new data and to selects the current one and then to use them in your project.

But my advice is to use Database. The categories are not too much data to be stored. It's far more flexible and powerful.

Ivan Stefanov
+1  A: 

If you think you will be adding new categories in the future, it is not static, and should probably be stored in a database. Since it won't be changing constantly while the app is running, you can have your app cache this data in memory when it starts up to avoid constantly querying the database for this list.

FrustratedWithFormsDesigner
+1  A: 

I do not see a valid reason not to use database for that, specially if you already do for some other data. Small tables like this are common. File storage, like XML or text file, could be good choice if you want to completely avoid database access.

Nenad
+1  A: 

If you are using a database for other storage in your app, then store it there in a lookup table. You can cache the query to get the list so that there is no unnecessary trips to the DB if that is what you are implying by waste. So I would base the decision based on what you are using otherwise for a repository.

Turnkey
+1  A: 

Store it in the database. It would be a waste of regular disk space if you don't do it. If you talk about "some catagories will be added from time to time", there is no real gain in data amount. Keep in mind that the databases of big companies/sites/applications/... store billions of rows of data so it will be no problem, if you store your categories. This way, it will be easier for the app to "just" work with SQL for data retrieval as if there will also be XML or alike.

DrColossos
A: 

You should store the categories in a relational table to ensure your constraints are valid (in this case, one category per book, correct)?

You won't encounter much wastage in terms of storage or cost (query performance). In fact, I'm pretty sure you'll want to query books by their category, so this is a logical design for you.

RobS