Reputation: 1114
What is the best practise for logging activity in a WCF service to a database (sql server), so that it later can be reviewed in a UI.
I have checked with a couple of persons and one says that I could save the message as xml in a xml column in the database, whilst the other says that it's better to save it in standard relational tables.
The thing that points to the first solution (xml based) is that it simplifies the solution based on the fact that the business object sent from the service contains list properties. It does on the other hand introduce some complexity for handling the data and will probably require some kind of table-like view.
The plain old tables, however, makes it more complicated to save the list properties in a smart way. On the other hand, it's simpler to write queries and use the data for possible future data warehousing/analyzing.
Another thing that worries me is if/when the business object changes (schema). Which solution makes it easier to handle that and in what way (specially for the UI part).
Upvotes: 1
Views: 293
Reputation: 31651
Why not do both? Use an XML column that supports the unstructured flexibility you seek combined with multiple structured fields enabling easier filtering & viewing capability.
It's really a matter of opinion - there is not a correct answer for this question. I've seen it done both ways as well as the hybrid approach suggested above. It just depends on your needs. Displaying XML in the UI isn't that much more difficult than single-value fields - you just need the right toolset (see LINQ to XML, XML Computed Columns, & XML Indexes).
Upvotes: 1