Boost logo

Boost Users :

From: Christian Henning (chhenning_at_[hidden])
Date: 2007-03-15 12:12:37


> > I like and use SOCI, as well. Although, today I found out about
> > litesql and I like their approach of generating c++ code from xml
> > based table definitions. So, I think a cross of both would be nice.
>
> Interesting, but this seems fairly limited to a very specific mapping. What
> if I need to change the mapping names or key associations? And, I have come
> out of the closet -- I hate xml as a primary 'input language'. If you're
> going to all the trouble of writing a generator, why not write one with
> simplified data specification language?
>
OK, admittedly I'm not a db professional but changing the mapping in
runtime? Isn't this like asking for trouble?

Does a simplified data specification language exist?

Another idea is have a graph representation of the model in memory.
Something like using boost::graph, maybe?

> Off the top of my head -- imagine something like more like this:
>
> schema example {
> type Mother; //forward declare
> type Father;
> type Office;
>
> type Role {};
> type Employee : Role {
> //1 to many bi-directional, required
> Office office <-> employees[0..*];
> }
> type Office {
> Employee employees[0..*] <-> office; //needs to match Employee
> }
>
> type Student : Role {
> }
>
> type School {
> string name;
> }
>
> //alternative way to specify a relation outside the type
> //Student will have an optional relation to school
> //School will have 0 to many students
> relation StudentSchool {
> Student.school[0..1] <-> School.students[0..*];
> }
>
> enum Sex { Male=0, Female=1 };
>
> //The obvious mapping Table = Person
> type Person {
> string name; //mapped to column name in table Person
> Sex sex;
> integer age = 0;
> //automatically generates Table PersonRoles
> Role roles[0..*]; //unidirectional 0..m relation
> //Generates a field for mother id
> Person mother; //unidirectional required relation
> Person father;
> //automatically generates a join table PersonSiblings
> Person siblings[0..*] <-> siblings[0..*];//bidirectional m-m
> };
>
> }
>
> database Exampledb uses schema example;
>
Looks nice it that coming from your imagination only? ;-)

Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net