Greetings! I am sorry for my poor English, but I need some help or maybe an advice.
I am writing an application that will store elements into a MySQL database.
The elements' members are variable width, but not more than 50 per element.
Which is better: to have a 50 column table in my MySQL database and insert data in the corresponding columns or create for example a 10 column table with one BLOB column and fit the required data in there?
Perhaps an example will do better:
1 2
|
MySQL Table:
id | name | description | property1 | property2 ... | property50
|
Inserting as follows:
|
INSERT INTO table (id, name, description, property1,property2,property3) VALUES (Object1.id, Object1.name, Object1.description, Object1.property1, Object1.property2, Object1.property3)
|
and leave the cols from property4 to 50 empty, or doing the following:
1 2
|
MySQL Table:
id | name | description | properties /*BLOB*/
|
while reconstructing the object as
1 2 3 4 5 6 7 8 9 10 11
|
struct DataObject {
string name, description, *properties;
int id, property_count;
} Obj1;
Obj1.property_count = getPropertyCount(); //this function counts the properties;
Obj1.properties = new string[Obj1.property_count];
Obj1.properties[0] = "property";
Obj1.properties[1] = "whatever...";
...
Obj1.properties[20] = "more stupid data";
|
and inserting the whole Obj1.properties into the blob field. Which is going to be better for the database and for the application performance. This is going to run on an embedded system (only the program, not the MySQL server) so I need it as light as possible. Thank you in advance