XML and SQL database


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
 
Ad

Advertisements

P

pennanth

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
 
Ad

Advertisements

S

shapper

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top