0

I have a complex data model with lots of attributes that I need to store. Since there's no need for searching on the attributes in the database (I'm using Lucene.Net for the search) I don't want to create tables and columns for the details of the model, rather I want to serialize the whole model and store it in a TEXT column.

One of the issues for this approach is maintainability; specifically, when the data model needs to change. There might be occasions in the future where there should be some convert mechanism to update the already-stored entities.

Which type of serialization (JSON/XML/other) and which implementation is more appropriate for such scenario?

Iravanchi
  • 5,139
  • 9
  • 40
  • 56

2 Answers2

0

Have a look on EAV approach.
That will use a RDBMS as data storage but not in a relational fashion.
It is not a recommended pattern in relational database design category, but that will serve on specific problems where the schema is attended to change very frequently (even no schema).
Logging entity changes is a good sample.

Note that If the EVA approaches is going to be applied on relational data model that JOINs are inevitable part of queries, using EVA would be an anti pattern.

The pattern is a base for no schema DBMSs.

Community
  • 1
  • 1
Mohsen Heydari
  • 7,256
  • 4
  • 31
  • 46
0

I've done something similar previously with JSON. Specifically using the JSON.NET serialiser.

You need your model classes to all support parameter less construction but it does handle scheme changes quite well.

Because you serialise and deserialise to strongly typed objects, if you add a field ten existing data will return null on those properties and whilst data wrapped in unknown properties is ignored.

kidshaw
  • 3,423
  • 2
  • 16
  • 28