views:

691

answers:

4

Hi,

I am currently working on a web application that requires certain requests by users to be persisted. I have three choices:

  1. Serialize each request object and store it as an xml text file.
  2. Serialize the request object and store this xml text in a DB using CLOB.
  3. Store the requests in separate tables in the DB.

In my opinion I would go for option 2 (storing the serialized objects' xml text in the DB). I would do this because it would be so much easier to read from 1 column and then deserialize the objects to do some processing on them. I am using c# and asp .net MVC to write this application. I am fairly new to software development and would appreciate any help I can get.

A: 

The answer for this really depends on the details. What kind of data are storing? How do you need to query it? How often will you need to query it?

Generally, I would say it's not a good idea to do both 1 and 2. The problem with option 2 is that you it will be much harder to query for specific fields. If you're going to do a LIKE query and have it search a really long string, it's going to be an expensive operation and you'll likely run into perf issues later on.

If you really want to stay away from having to write code to read multiple columns to load your data, look into using an ORM like Linq to SQL. That will help load database tables into objects for you.

ajma
A: 

If the number of this kind of objects is large and the size of it isn't very large. I think that using the database is a good idea.

Whether store it in a separate table or store it in the original table depends on how would you use this CLOB data with the original table. Go with option 2 if you will always need the CLOB data when you access the original table. Otherwise go with option 3 to improve performance.

A: 

You need to also think about security and n-tier architecture. Storing serialized data in a database means your data will be on another server, ideal if the data needs to be secure, but will alos give you network latency, whereas storing the data in the filesystem will give you quicker IO access, but very limited searching ability.

I have a situiation like this and I use the database. It also gets backed up properly with the rest of the related data.

ck
+2  A: 

Short answer: If option 2 fits your needs well, use it. There's nothing wrong with storing your data in the database.