For learning and understanding purpose, I currently want to try to make a small relational DBMS
with simple features like (for now) only sequential reading/writing and CREATE TABLE, INSERT, SELECT, UPDATE and DELETE management.
I am currently on the “think” part of the project and I am stuck on the way to store the read data in memory. First I was thinking of putting them properly on a structure, but the problem is that tables are all different, know the type of each column is not an issue, but I am not sure C provide a way to make fully dynamic structure.
My second and current idea is to make a simple char array
of the required length and just get the data by order with cast. But I am not sure if it is the good way to do that part, so I wanted to ask for your opinion and advices about that.
Thanks in advance for your help.
nb: I hope my question is enough clear and understandable, I still lack of pratice in english
3
It has been a long time since I programmed in straight C, but I think I can point you in the right direction. There are 2 things you can use together. First somthing like:
union data {
// all the data types you will support
}
You will need a way to identify each element. That is where struct can come in:
struct dataNode {
data *value;
// some type id system with either enum or ints
}
A row of data then becomes a linked list & a result set a linked list of linked lists. You will probably need to straighten out the syntax, but it is a start.
1