XML and SQL database

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have a XML file as follows:

<Posts>
<Post>
<Id>1</Id>
<Title>Asp.NET MVC</Title>
<Body>Some stuff</Body>
<Created>10-10-2008</Created>
<Tags>
<Tag>Asp.Net</Tag>
<Tag>MVC</Tag>
</Tags>
</Post>
</Posts>

Or I could use 3 tables (Posts, PostsTags and Tags):

<Posts>
<Post>
<PostId>1</PostId>
<Title>Asp.NET MVC</Title>
<Body>Some stuff</Body>
<Created>10-10-2008</Created>
</Post>
</Posts>

<Tags>
<Tag>
<TagId>1</TagId>
<Name>Asp.NET</Name>
</Tag>
<Tag>
<TagId>2</TagId>
<Name>Mvc</Name>
</Tag>
</Tags>

<PostsTags>
<PostTag>
<PostId>1</PostId>
<TagId>1</TagId>
</PostTag>
<PostTag>
<PostId>1</PostId>
<TagId>2</TagId>
</PostTag>
</PostsTags>

Basically this replicates the SQL database tables.

Then I get the data into objects using Linq and joins on the XML files
or not?

Which approach do you use when working with XML files?

Basically sometimes I have a project where an SQL server database is
"to much" and the client does want to pay the extra money for the SQL
Server hosting. So I use XML files.

I am not sure if I should use the first option where I just use a
"Flat" format as usual in XML files or use the second approach to try
to replicate the database tables.

I am using Linq and C# for this.

Thanks,
Miguel
 
Hi Miguel,

You can you XML serialization/deserialition to create .NET objects
corresponding to your XML objects. Use xsd.exe tool to create XSD for your
XML if you don't have XSD, and then use XmlSerializer class to create your
classes.

After you create your objects, you can store them either in form of XML
files, or persist them into object database like Eloquera
(http://www.eloquera.com/) to be able to run queries against your objects.

Regards,
pennanth
 
XML Serialization to the file system is widely used. Here's a document I was
perusing just this afternoonhttp://bit.ly/1AofGs

Something is wrong with the link. Could you repost it?

Thanks,
Miguel
 
Back
Top