building a database

pls i have a project to build a database using c++ but the only thing i know about c++ is the hello world program
How did you go from "Hello World" to "make a database" with nothing in-between?
L B:
How did you go from "Hello World" to "make a database" with nothing in-between?

lol

Edit: on a more serious note, there's no way for you to design, implement and maintain a C++ database ( like SQLite: http://www.sqlite.org/ ) if the best you can do is a "Hello, world!" program. Move into conditionals or loops as a next step instead.
Last edited on
@Josue: when he says "I have a project" I think he means for a class. We can only assume what his attendance records are...
@L B, I pray to God he means a personal one.
By the by, do you think that writing a "toy database" would be a useful (even interesting?) project for someone who has (more or less) completed all the tutorial materal on this site?

We get people asking for project ideas from time to time, and I was wondering about this as a possible, future suggestion.

To keep it simple, you'd start off by:
1. storing the data for the "tables" as tab-delimited (or similar) text files
2. working only with string data
3. stick to as small a subset of SQL as possible, e.g.

SELECT * FROM Persons WHERE COL1=123;
SELECT ID, Name FROM Persons;

INSERT INTO Persons(ID , Name ) VALUES (123, 'Bill');
DELETE FROM Persons WHERE ID=123;

CREATE TABLE Persons (ID varchar(255), Name varchar(255));
DROP TABLE Persons;

To get there you'd need to apply the following knowledge:

a. files (ifstream, etc.) -- to load the data
b. standard containers (vector, etc) -- to hold the data
c. string -- to store the individual pieces of data
d. plus loops, if-statements, etc.

This should get you to the point where you can load a data table into memory, which I'm assuming would be created with a text editor to start with.

Then to find the data (handle SELECT statements) you'd need:

e. string parsing (string) -- to parse the query string
d. string matching -- to find the relevant entries
f. algorithms -- to find the matched (though you could use a loop here.)
(plus everything from before)

Etc.

It's complicated enough a problem that it would require a bit of up front design. And it will require the use classes, etc.

And could be taken further by adding type handling and extending the SQL support.

Andy
Last edited on
Topic archived. No new replies allowed.