Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good idea to store serialized objects in a Database instead of multiple xml text files?

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.

like image 920
Draco Avatar asked Dec 14 '25 19:12

Draco


2 Answers

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

like image 169
user64075 Avatar answered Dec 16 '25 11:12

user64075


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.

like image 30
ajma Avatar answered Dec 16 '25 12:12

ajma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!