Bohdan wrote:
"Vladimir Prus" <[EMAIL PROTECTED]> wrote in message
arb8od$c87$[EMAIL PROTECTED]">news:arb8od$c87$[EMAIL PROTECTED]...
Bohdan wrote:
I believe that XML can contain any data. But i suspect that
XML garbaged with all serialization stuff will be
1. unreadeable
2. difficult to handle automatically (by other programs).
So i was thinking about simplifying Object <-> XML serialization.
Recently there were talks about ditto & relational algebra libraries.
Also there was message about stl container on disk.
As i understand at least some of these libs require special kind
of serialization: Object <-> Relational tuple (object-relational mapping).
Having such mapping it would be easy to put Relational data to XML.
And in this case XML will be very readable.
Wouldn't there be a problem with converting object with variable size?
How can you store vector<int> in a relational database? I don't see an easy
way.
Relational record field can be of simple type (int, char[n], double) or
it can be other nested table. In your exapmle:
vector< int > ->
record
{
nested_table_field
{
record
{
field<int>
}
}
}
I'm not a database expert, so my knowledge may be just rusty. However, I never
heard about composite types in relational tables, and never seen anything like
that in MySQL. Looking at MySQL docs right now, I indeed see no mention of
composite types. Could you clarify, preferably with concrete SQL syntax.
I know this approach has some limitations and doesn't fit very well
to serialization library design, but IMHO Object <-> relational tuple
conversion would be very useful :
1. store/retrieve object to/from relational tables (in-memory & disk
databases).
Do you think that automatic mapping is possible in case of relational
database?
No. Serialization lib also is not automatic. I think user should define mapping
information manually. But if you have only one side object definition (header
file)
or relational dabase schema (DDL) and you want to build other side automatically
than it is possible to create some tool that does it automatically.
How this mapping will be defined? Can you give some examples? Especially,
why this mapping can be defined in the same way as for serialization (given
additional "begin_composite/end_composite" hooks?
Of course, you might have Berkeley DB or something like that, which is
on disk map<string, string>. But in this case, Robert's serialization
library would work just fine. And BTW, I'd like to have such thing.
I don't know much about Berkley DB, but it looks like it is not relational
db (record==serialized object ?). It is very limited comparing to fullblown
relational database.
It's just a different beast.
But i agree it would be very useful to have something
like that.
OK.
I can see it as some kind of "builder" interface:
- create table <record schema>
- add field of <simple type>
- add nested-table field
simple example:
<code>
class A
{
public:
int x;
char y[100];
static void define_table( builder & b, table& t )
{
b.define_field( t, "X", int_field );
b.define_field( t, "Y", char_field, 100 );
}
void add_record( table& t )
{
record& r = t.new_record();
r[ "X" ] = x;
r[ "Y" ] = y;
r.save();
}
};
Ah.. so here's example. The only problem with implementing this
in the same way as for serialization, is that you'd need to
define database structure before serializing. It's quite possible,
if the 'reflection' layer is designed to support this use case.
- Volodya
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost