Sign in to follow this  
Zyndrof

Database programming?

Recommended Posts

Zyndrof    163
Hi there! After surfing some open source databases lately I found myself very interested in knowing how they work, and create my own database environment (don't worry, I do NOT have plans on trying to create a MySQL clone). I just want to try make something very simple. Something that can store, insert, update, delete and view items through SQL-statements. My problem is that I haven't got a clue about how databases actually work. I can use them in my code though so I'm not completely dumb on the subjuect. My cry for help includes articles that explain the design of databases, how they work and interact with the code, and offcource everything else that I've failed to think about :) Thanks in advance!

Share this post


Link to post
Share on other sites
lightbringer    1070
You might as well start with this classic paper to get you thinking about relations, domains, tuples, etc, as well as the SQL-92 specification, since you aim to implement some subset of it. There are more modern versions of the specification but they contain many things that you won't care about for a very simple relational database, such as object orientation and advanced data types.

The internal implementation I am not sure of, but you have this interface/language definition on the one hand and files on the filesystem on the other hand, with the "relational model" in between. Since you are starting out with a language "source code" you will need to write an SQL parser to figure out what the user actually wants to do, verify if it's legal, and map it to internal commands, although there are many general SQL parsers available, some of them open-sourced. On the other hand you have the question of storing tables in files and efficiently querying and updating them (the storage engine). There's also the questions of managing user permissions via logon and grants, maintaining referential integrity, etc.

There also is a lot of interesting and relevant info on this topic over at the Wikipedia.

Share this post


Link to post
Share on other sites
Kanzure    126
Lightbringer's post is excellent, and so I am only going to add that you might want to do some snooping around in the source archives at SQLite, though the little database manager has been known to do some weird things, like not cache the database or flush multiple updates at the same time, etc. Edit: koders.com- the code search engine might have more database sourcery to play with.

- Bryan

Share this post


Link to post
Share on other sites
Antheus    2409
Another thing to keep in mind: Relational Databases are probably one of bigger research areas since they were introduced. Post-PhD people and corporations backed by billions of dollars are constantly working on resolving all aspects related to them. And then, there's Google, running database probably in petabytes, distributed over tens of thousands machines.

In simplest form, a relational database is a hash table, mapping between Key and Value.

Simplest implementation can be done in 5 lines of Java code using HashMap class. It's also not that difficult to implement SQL compliant storage using the same method.

But, as always, the devil is in the details. And since most universities still offer Database theory courses longer at least equal in scope to those of Graphics, AI or Systems, you can imagine there's *a lot* of theory.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this