Regarding storing structures in database
-
I need to store a structure in a database..but the structure contains another structure..can anybody help me plz
-
I need to store a structure in a database..but the structure contains another structure..can anybody help me plz
-
I need to store a structure in a database..but the structure contains another structure..can anybody help me plz
Given that you have two structures, you need something like a foreign key to resolve them when loading them from database. Given there is structure #1:
struct numberOne{
int childStructId,
int someValue
};and struct #2:
struct numberTwo{
int id,//needs to be unique
int anotherValue
};You need now a database which has two tables, one to store struct #1 and another one for struct #2: The table for struct #1 has two fields, for the childStructId and onther one for someValue. The table for struct #2 has also two fields, one for its unique Id and another one for anotherValue. Afterwards you can load struct #1 from database, and according to the childStructId you can load struct #2 from the database. I was just guessing what you want, please come back to me if you have further questions.
cheers Marco Bertschi
You have absolutely no idea how glad I am that I have no idea at all. - OriginalGriff I'm at peace with the world and myself. - Me
-
Given that you have two structures, you need something like a foreign key to resolve them when loading them from database. Given there is structure #1:
struct numberOne{
int childStructId,
int someValue
};and struct #2:
struct numberTwo{
int id,//needs to be unique
int anotherValue
};You need now a database which has two tables, one to store struct #1 and another one for struct #2: The table for struct #1 has two fields, for the childStructId and onther one for someValue. The table for struct #2 has also two fields, one for its unique Id and another one for anotherValue. Afterwards you can load struct #1 from database, and according to the childStructId you can load struct #2 from the database. I was just guessing what you want, please come back to me if you have further questions.
cheers Marco Bertschi
You have absolutely no idea how glad I am that I have no idea at all. - OriginalGriff I'm at peace with the world and myself. - Me
sir, first of all thank u so much for ur reply.. what i need is for example there is a structure struct example { int id; string name; struct example2 { int value; } }; now i need to store this structure in a database...as i'm new to database i dnt have any idea of it...so plz help me...also i'm using sqlite3 database
-
sir, first of all thank u so much for ur reply.. what i need is for example there is a structure struct example { int id; string name; struct example2 { int value; } }; now i need to store this structure in a database...as i'm new to database i dnt have any idea of it...so plz help me...also i'm using sqlite3 database
Member 7894601 wrote:
first of all thank u so much for ur reply..
You're welcome.
Member 7894601 wrote:
now i need to store this structure in a database...as i'm new to database i
dnt have any idea of it...so plz help me...also i'm using sqlite3 databaseYou can find an intro of how to connect to a SQLite database at the SQLite website[^]. The people of the Database forum[^] will help you to find out which tables you will need to create a reliable database.
cheers Marco Bertschi
You have absolutely no idea how glad I am that I have no idea at all. - OriginalGriff I'm at peace with the world and myself. - Me
-
sir, first of all thank u so much for ur reply.. what i need is for example there is a structure struct example { int id; string name; struct example2 { int value; } }; now i need to store this structure in a database...as i'm new to database i dnt have any idea of it...so plz help me...also i'm using sqlite3 database
You may create two tables where one contains a reference (foreign key) to the other:
TABLE example2
INT id unique ID, usually auto increment
INT valueTABLE example
INT id
VARCHAR name
INT id2 foreign key to access table example2 -
You may create two tables where one contains a reference (foreign key) to the other:
TABLE example2
INT id unique ID, usually auto increment
INT valueTABLE example
INT id
VARCHAR name
INT id2 foreign key to access table example2but initially how to create a database with two tables using sqlite3
-
but initially how to create a database with two tables using sqlite3
Searching the web for 'sqlite tutorial' should help. http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html[^] is one result which shows you how to create a database and add tables to it.
-
I need to store a structure in a database..but the structure contains another structure..can anybody help me plz
Member 7894601 wrote:
can anybody help me plz
The first step is that you need to learn - How to create a database - How to create tables - How to store and retrieve data from a table None of that has anything to do with your structures, so don't try to do that until you understand the above.
-
Member 7894601 wrote:
can anybody help me plz
The first step is that you need to learn - How to create a database - How to create tables - How to store and retrieve data from a table None of that has anything to do with your structures, so don't try to do that until you understand the above.
Sir, i am nw able to create a database...nw my requirement is how to store the details of files and folders in the database..
-
Member 7894601 wrote:
can anybody help me plz
The first step is that you need to learn - How to create a database - How to create tables - How to store and retrieve data from a table None of that has anything to do with your structures, so don't try to do that until you understand the above.
sir, nw i am able to create a sqlite3 database...but nw i face a problem of storing a variable which is wchar_t...which datatype should i use...plz help me