Thread: Simple Database

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    3
    Rep Power
    0

    Simple Database


    Hello,

    I was just wondering what the best way to make a simple database for a light weight cataloging program let's say. So, probably, the most enteries would be 50 000 (big number to be safe).

    So, for each table, would there be 3+ files? one for the actual data, one for the table structure, and one for each collumn index. So, would we have to load the whole data file and index files in memory before accessing the data? Ok, so let's say the table has 2 collumns one is a byte number (for indexing), and the other is 2 chars. So, in the datafile, we would just append bits.. padding each value with 0s in the front. Also, we could have a bit saying if the line were defined (in case we delete it). ex:

    1 00000001 00001000 00000010
    1 00000010 00000010 00010010
    0 00000000 00000000 00000000
    1 00000011 00001010 11001110

    etc... but the bits would just be stuck one after the other... And then when a line is deleted, just change the first bit to 0.

    Now, the index files, would be one file per index, and would just be mini version, having whatever column is indexed in order, and information to reach the appropriate row in the data file.


    Now, what the flaws I came up with this system, is that I couldn't think of an easy way to deal with the index when appending / deleting rows. Because with the datafile, just append rows at the end, but with the index files, you have somehow put them in order, so you would have to shift all the bits after whatever row is being inserted down, and when deleting, shift all the bits up.

    Also, I don't know if it's possible to get all the bits in memory linearly.

    Bassically, I have no idea how real databases work, and this is just something that I came up with just by thinking of the problem. I'm considering writing an application where I would need to use this, that's why I thought of it.

    Carl

    Comments on this post

    • JimmyGosling agrees
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jul 2001
    Location
    Oslo
    Posts
    1,516
    Rep Power
    14
    Well I've just started a course in database theory, so in a couple of months I can tell you Anyway, I would suggest a book on the subject as the techniques for this kind of thing are pretty standard, unfortunately I can't recommend the book we're using in my course, simply because I haven't finished it yet... ("Database systems, the complete book" by Garcia-Molina, Ullman and Widom, in case you wondered).

    Comments on this post

    • JimmyGosling agrees
    --
    Regards
    André Nęss

    Puritanism: The haunting fear that someone, somewhere may be having fun
  4. #3
  5. No Profile Picture
    small, green, and connected
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    FL, SC
    Posts
    63
    Rep Power
    13
    As interesting as it would be to implement a database oneself, if you really do end up having to make such a catalog, I would strongly (oh, so strongly) recommend using something simple, fast, free, and already working lik MySQL or PostreSQL.

    -wg <><

    Comments on this post

    • JimmyGosling agrees
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    3
    Rep Power
    0
    Well, if I do that, I would have to include MySQL with the program.

    And right now, when I make programs, it's more for me to learn I'm a college student right now, and I like learning (well, I like learning what I want to learn)

    -cARL

    Comments on this post

    • JimmyGosling agrees

IMN logo majestic logo threadwatch logo seochat tools logo