Results 1 to 11 of 11

Thread: XML Databased System

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    XML Databased System

    I'm starting a new site and some of the feature they want are making me consider using an xml data structure. The first thing I considered when I though of this is making my data object serializible and simple seralizing and deserializing my objects as the methos of handling the data.

    I don't see many downsides to this. I may have to write a hefty search function and a method to sort the data, but as I see it right now the fact that I only have to inherit from my base class serial and overide it's DataRoot property to make a data object save, update and delete/export looks good to me.

    What do you guys think?

    Code:
    	[System.Serializable]
    	public abstract class Serial
    	{
    		/// <summary>A class Implamenting Serial should overide this property to provide it's root data directory.</summary>
    		protected abstract string DataRoot{get{return "";}}
    		private System.Guid _key;
    		/// <summary></summary>
    		public System.Guid Key{get{return _key;}}
    		/// <summary>Used internally by the inherating class to load saved data.</summary>
    		protected object Load(System.Guid key)
    		{
    			System.IO.FileStream fs = System.IO.File.Open(DataRoot + key.ToString(), System.IO.FileMode.Open);
    			System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
    			
    			object o = bf.Deserialize(fs);
    			fs.Close();
    			return o;
    		}
    		/// <summary>Saves object data to it's DataRoot.</summary>
    		public void Save()
    		{
    			if(_key.ToString() == null || _key.ToString() == ""){_key = UniqueKey();}
    			System.IO.FileStream fs = System.IO.File.Create(DataRoot _key.ToString());
    			System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
    
    			bf.Serialize(fs, this);
    			fs.Close();
    		}
    		/// <summary>Get's a unique key for the DataRoot.</summary>
    		protected System.Guid UniqueKey()
    		{
    			//this is not fool proof another item in another folder could have the key
    			//but nothing in here would be affected so does it matter?
    			System.Guid g = System.Guid.NewGuid();
    			if(!System.IO.File.Exists(DataRoot + g.ToString())){return g;}
    			return UniqueKey();
    		}
    	}
    
    
    	public class Class1 : Serial
    	{
    		public Class1(){}
    		public Class1(System.Guid key)
    		{
    			Class1 c = (Class1)Load(key);
    			//populate data properties
    		}
    
    		protected override string DataRoot
    		{
    			get
    			{
    				return "folder data files are in";
    			}
    		}
    	}
    Magiaus

    If I helped give me some points.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I don't have experience with storing things in XML files for a web site. I do know that as XML files get bigger and bigger, they tend to take longer to load and process. If you are storing them all as different files, then it probably won't be bad.

    If I had a choice, I would store everything in a database as my first choice. Last choice would be XML for me. To me, database queries, stored procedures, etc are faster to get data, especially when there is a lot of it.

    Just my opinion though. Is there a business reason for not going for a database approach?

  3. #3

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    Server space mostly. And cost. I'm trying to figure out how I will sort, search and so on. I suppose I could bubble sort or something. I don't know yet.
    Magiaus

    If I helped give me some points.

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    The sorting and searching performance gains are enough reasons to pick a database over xml for me. The searching and sorting routines have been polished over years in most database tools and are highly optimized.

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Magius brings up a good point though... server cost.

    For a small website that doesn't need much space, like my wife's photography website... it costs an additional $190 a year for use of a SQL server to store the database that drives part of the website information.

    Now, $190 /yr is pretty damn cheap, but XML files are completely free. In her scenario, her 'database' needs will never outgrow 5mb. I have it designed using a SQL database, but I will look into XML flat files myself as an alternative at some point, or (gulp) an access database.

  6. #6

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    XQuery..? I dunno what the heck it is, and it looks creapy. Like some SQL, PHP Hybrid, and it's not a standard yet..... it uses for loops...... For element type deal...

    If any of you have ever heard me talk about xml in the vb.net foroum you know i tend to think it's overly redundent and goes toward job security more then anything..... but I'm starting to see a dim light. Maybe in a few more years it will be woth useing if you have an XML Server. Right now though it looks like if you had a major data system to build xml is going to be a heavy weight to lift.

    I am looking at using a folder name = table name scenerio and a simgle element is a single file named after it's key. but even with this to find something based on say name or searching or whatever. I have to write the method to do this. I'm okay I can almost spell algorythm, but where is the line between paying for SQL Server and paying for me. I'm not too cheap either. my 8hrs of writing the algorythm could probaly bank SQL Server for a year. Also most likely unless I figure something out in the proccess of writing the rythm. If I want to do this again I'll need a new rythm.

    XQuery...?
    Magiaus

    If I helped give me some points.

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by nemaroller
    Magius brings up a good point though... server cost.

    For a small website that doesn't need much space, like my wife's photography website... it costs an additional $190 a year for use of a SQL server to store the database that drives part of the website information.

    Now, $190 /yr is pretty damn cheap, but XML files are completely free. In her scenario, her 'database' needs will never outgrow 5mb. I have it designed using a SQL database, but I will look into XML flat files myself as an alternative at some point, or (gulp) an access database.
    I spend only 120 dollars a year on hosting, which includes asp.net and sql server.
    www.webhost4life.com

    10 bucks a month for everything isn't bad at all, especially for a business.

    Now, if you are doing high volume, then you probably want a dedicated server. In that case, you still wouldn't want just XML files because you need all the speed you can. I guess you could keep the XML files in memory for speed, but then you have server memory size issues...

    The trade offs you make are sometimes hard. I look at it like if you have access to a database, it would be wise to use it. I know XML can replace the database in certain places, but not most places.

  8. #8
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Damn that's a cheap host...

  9. #9

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    mine is pretty cheap too. I get the works with SQLServer for about $270 a year. This client has a host already though. Wants to stay with them even though they are more expensive. Allot more.
    Magiaus

    If I helped give me some points.

  10. #10
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by Magiaus
    mine is pretty cheap too. I get the works with SQLServer for about $270 a year. This client has a host already though. Wants to stay with them even though they are more expensive. Allot more.
    Well, in that case, you are probably going down the right direction.

  11. #11

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    I think so too but it is going to be a painful. I am looking right now at putting key%subcat%name as the file name. That way maybe I can only read the filename and then load the file or not load the file. This seems like it might be a good idea, but I dunno. thinking.....
    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width