• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping different XML documents to a single database schema?

 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, I have a request processing system which receives slightly different XML messages from different sources (client applications). The requirement is that every request needs to be logged into a database. Now, the question remains, how should I design the database schema for storing these log entries when one complex element in the incoming requests varies?
Of course I could have a table per different "variant" section, but I wouldn't want to go there because the number of these variants may grow over time causing maintenance headache.

Here are two example requests that should be possible to handle (the exact XML schema is not written in stone, though). Basically, the DTD for these requests would specify something like <ELEMENT request (securitycode, country, model, (sms | ivr))> where there's always either an "sms" or "ivr" element (and possibly something else in the future) and the contents of these alternatives are different.

 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you log them for? How do you need to retrieve them?
Could you simply write the XML into a CLOB/BLOB?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you log them for? How do you need to retrieve them?
I don't know... I will after 3 hours when I have a chance to discuss with the customer. I'm basically doing research on the alternative approaches for each scenario.
Could you simply write the XML into a CLOB/BLOB?
Yes, I could. And that's what I'll probably end up doing unless the customer has something in mind for the future. Based on what we know right now, the simplest thing would be to add two columns into the existing table and simply leave the other column unused for half of the requests.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO, I would avoid the whole BLOB/CLOB thing if possible. You pretty much kill any searchability and flexability by doing this. Based on the examples you gave, I might think about something like this:

Given the above schema, your populated tables might look like this given your data:

So yeah, you have more than one table, but it's not a big deal if you need to add additional variants other than SMS or IVR in the future, since you can see how all these sections are joined to the main request. Just add a new table, with a foreign key field for the REQUEST_ID, for any new sections that come along.
[ December 01, 2003: Message edited by: Jason Menard ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic