Skip to main content
GameDev.net gamedev.net
🔒 Locked

XML Database

Started by Griwes Sep 14, 2010 at 8:40 AM 0 replies 550+ views
Original Post
Griwes
Griwes
I am working on simple XML database engine and I have few questions to more experienced programmers:

1. Is there point in storing each element in it's own file or it is better to store all entries of same type in one, potentially big file?
2. When storing every object in one file, this problem does not exist, but when operating on many small files, how to implement "where" queries? In other words, how to quickly find all matching files?

Let's say we have following object type - image info:
- name - string - main index
- path - string
- size - integer
- description - string

name, as main index, may be cached in some kind of index - identifier map, but what if we query database for every entry that has size < 4*1024*1024?

3. If using one big file for each type, is there way to get some parts without having entire file kept in memory?
ApochPiQ
ApochPiQ
Why aren't you using any of the existing, tested, debugged, reliable database solutions available (XML or otherwise)? Reinventing wheels is bad.


Now, a few comments:

  1. What is an "element"? What is an "entry"? Are you following the relational normal forms for defining your data, or some other structure? How big is each "element" (whatever that is) likely to be? This question cannot be answered meaningfully without some actual information about what you're doing.

  2. Why would you store every field in a different file? Do you even know how XML works? This question doesn't even make sense, sorry.

  3. If you really need this (i.e. you have multi-gigabyte data tables and you are not able to use 64-bit platforms) then just store the offsets to various tables/records in a separate file, and seek to those positions instead of scanning the entire file each time you open it. Note that this will make your life a complete hell because you will have to write an XML parser that can recover its state at arbitrary file offsets rather than parsing the entire document tree the way it was meant to work. However, you don't need this. Just load the file into memory and deal with it there.



Again, what kind of experience do you have with XML in the first place? It doesn't sound like you really have any idea what XML is meant for, or what databases are typically used for, or anything of the domain requirements. Is this just a fun project or are you trying to solve a particular problem? If it's just a side project, why aren't you studying up on existing solutions first so you can learn from them, rather than just blindly trying to do something that is already well-understood?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.